我正在从 https://github.com/borisyankov/DefinitelyTyped 导入我的大部分 DefinitelyTyped 模块与 nuget。
我想知道是否遗漏了什么,因为我发现它们都缺少 AMD 支持。
在大多数模块中,我自己添加了这个:
declare module "toastr" {
export = Toastr;
}
declare module "knockout.validation" {
export = KnockoutValidationStatic;
}
declare module "knockoutmapping" {
export = KnockoutMapping;
}
declare module "jquery" {
export = $;
}
执行此操作时,我可以执行以下操作:
import $ = require('jquery');
import toastr = require('toastr');
它会正确生成我的 AMD 模块。
define(["require", "exports", 'toastr'], function(require, exports, __toastr__) {
}
我想知道是否有其他方法可以做到这一点,因为我发现大多数库都缺少 d.ts 中定义的 amd 导出。
最佳答案
一些定义确实有这个部分,例如下划线。他们中的许多人不这样做的原因是因为导入的名称取决于您如何配置 requirejs 以及您在配置中选择的短路径名称。
关于typescript - DefinitelyTyped d.ts 文件和带有 TypeScript 的 Amd 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18561579/