typescripttoastr

How to get toastr to work in Typescript


I am converting a project over to Typescript. I am having issues with toastr.

import {toastr} from "toastr";

I downloaded the typescript definition file with Nuget and included it in the project.

It has this export at the end of the file:

declare var toastr: Toastr;
declare module "toastr" {
export = toastr;
}

However, I get the compile time error: Modle "toastr" has no exported member 'toastr'

How to I resolve this issue?


Solution

  • Try the following:

    import * as toastr from "toastr";
    

    Doing that will import the entire module as toastr.