如何让 toastr 在 Typescript 中工作

How to get toastr to work in Typescript

我正在将项目转换为 Typescript。我在使用 toastr 时遇到问题。

import {toastr} from "toastr";

我用Nuget下载了typescript定义文件并包含在项目中

它在文件末尾有这个导出:

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

但是,我得到编译时错误:Modle "toastr" has no exported member 'toastr'

如何解决这个问题?

尝试以下操作:

import * as toastr from "toastr";

这样做会将整个模块导入为 toastr