0
我需要的是如何導出打字稿類的Node.js與參數
require('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;
生成函數中沒有參數的位置。我該怎麼做?
所以你需要將打字稿轉換爲commonjs模式....正確。 – Jai