typescript - DefinitelyTyped d.ts 文件和带有 TypeScript 的 Amd 模块

标签 typescript

我正在从 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/

相关文章:

typescript - 找不到名称 'firebase' Vanilla typescript

node.js - Bot框架(v4)使用HeroCards在轮播中提示选择不进入下一步

javascript - 如何检测嵌套 div 中的溢出(React)?

javascript - Lodash - 显示对象的更改属性

reactjs - 在 React 中使用模态的项目列表上打开模态

javascript - 是否可以动态构建此功能?

javascript - Nest JS Guards - 使用两种策略之一

javascript - 在 AngularJS 应用程序的 Controller 父类(super class)中加载依赖项的正确方法是什么?

node.js - Sequelize destroy 无法测试真实性

angular - 有没有办法从存储为常规 Observable 的数组中返回单个元素?