Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 309
Greg Gum Avatar asked Aug 31 '15 19:08

Greg Gum


1 Answers

Try the following:

import * as toastr from "toastr";

Doing that will import the entire module as toastr.

like image 53
David Sherret Avatar answered Oct 05 '22 10:10

David Sherret