【发布时间】:2017-04-07 12:44:19
【问题描述】:
我需要的是相当于
的 Typescriptrequire('mytypescriptfile')(optionsObject);
但是TS码:
export class Animal {
name: string;
public bark(): string {
return "bark " + this.name;
}
constructor(color:string) { }
}
产生这个 JS 代码:
"use strict";
var Animal = (function () {
function Animal(color) {
}
Animal.prototype.bark = function () {
return "bark " + this.name;
};
return Animal;
}());
exports.Animal = Animal;
生成的函数中没有参数的位置。我该怎么做?
【问题讨论】:
-
所以你需要将 typescript 转换为 commonjs 模式......对。
标签: javascript node.js typescript