Tag: typescript2.2

使用Typescript API执行

我有一个Node.js模块,看起来像这样: module.exports = function(data){ return { limit: 4, values: {} } }; 使用TypeScript,可能看起来像: interface ISomethingA { values: Object, limit?: number } export = function(data: ISomethingB){ return { limit: 4, values: {} } as ISomethingA; }; 这些模块必须遵循某个API – 从函数返回的对象需要“值”和“限制”属性。 我可以在这里使用什么TypeScript结构来给用户提供反馈,以便他们知道他们正在遵守API? 到目前为止,“as”语法并没有像我所期望的那样为我工作。 我正在寻找一种方法来定义函数返回的对象的types。

将数组传递给asynchronous库eachSeries – 期望Dictionary <{}>'

我有以下TypeScript代码: const allDescribeBlocks: Array<ITestSuite> = suman.allDescribeBlocks; async.eachSeries(allDescribeBlocks, function (block: ITestSuite, cb: Function) { //…. }, cb); 这将会发出警告: typesITestSuite []的参数不可分配给typesDictionary <{}>的参数。 索引签名在ITestSuite []中缺失。 怎么修? 这是确切的警告:

将Typescript 2.3模块发布到NPM for Angular 4 Consumption

在Typescript中编写NPM模块有相关的说明,但是它的date和现在有很多不同的答案,可能会或可能不适用于angular4。 ,但在这种情况下,我只对发布香草打字稿感兴趣。

如何捆绑typescript-node-express应用程序

我想要构build一个完整的完整的Web应用程序。 我的服务器端代码是打字稿。 我想configuration我的项目,这将从以下的结构: projectFolder / src /(服务器端打字稿文件) – 连接一个index.ts主文件 projectFolder / public /(客户端代码) – 由index.ts提供expression代码。 projectFolder / serverCodeBundle.js 当我在我的服务器端代码工作时,我想要一些watch命令在backgorund中运行,并将所有我的ts文件捆绑到一些serverCodeBundle.js ,这样它将被源代码映射到原始的ts文件。 为了简单起见,我们假设我的服务器端代码如下所示(为简单起见,我已经提供了客户端代码服务): /src/index.ts: import {A} from './A' new A() /src/A.ts: export class A { constructor() { throw new Error("A error") } } 运行nodemon serverCodeBundle.js应该出现一个错误消息,指定错误来自A.ts. 我已经尝试了tsify [与require(“source-map-support”).start()在每个ts文件的开始(和仅在index.ts)和tsconfig中的sourcemap选项],但不能得到它上class。 有没有任何tsifyconfiguration,yeoman发电机或任何其他打包机可以做到这一点?