在AMD打字稿模块中使用Noty在运行时失败

使用npm安装了noty软件包的3.2.0-beta版本。 使用module: "amd"用打字稿(4.0)编译了以下代码:

import noty from "noty";

new noty({
    text: "A message",buttons: [
        noty.button("Save","noty-button",(): void => {
            console.log("Saving");
        })
    ]
});

编译成功,并且生成的js包含:

define(["require","exports","noty"],function (require,exports,noty_1) {

new noty_1.default({
    text: "A message",buttons: [
        noty_1.default.button("Save",() => {
            console.log("Saving");
        })
    ]
});

装有RequireJS映射,将“ noty”映射到“ ../node_modules/noty/lib/noty.min”。加载后出现错误:Cannot read property 'button' of undefined。这是有道理的,因为button是noty类的静态方法。

如果我删除了整个按钮部分,则错误更改为:noty_1.default is not a constructor

import * as noty from "noty";const noty = require("noty");也尝试了其他类型的错误。

我不知道这是否是noty类型定义文件问题,或者我做错了什么。在我尝试寻找替代方案之前,您能帮我吗?

感谢您的帮助! 马里奥

iCMS 回答:在AMD打字稿模块中使用Noty在运行时失败

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/1659050.html

大家都在问