你應該使用一個任務運行的工具,像Gulp它將使你的生活從長遠來看更容易...
下面是用來編譯一些單元測試和源與咕嘟咕嘟的配置示例:
// The TypeScript compiler settings
var tsProject = tsc.createProject({
removeComments : false,
noImplicitAny : false,
target : "ES5",
module : "commonjs",
declarationFiles : false
});
// compile app code
gulp.task("build-source", function() {
return gulp.src(__dirname + "/source/*.ts")
.pipe(tsc(tsProject))
.js.pipe(gulp.dest(__dirname + "/build/source/"));
});
var tsTestProject = tsc.createProject({
removeComments : false,
noImplicitAny : false,
target : "ES5",
module : "commonjs",
declarationFiles : false
});
// compile test code
gulp.task("build-test", function() {
return gulp.src(__dirname + "/test/*.test.ts")
.pipe(tsc(tsTestProject))
.js.pipe(gulp.dest(__dirname + "/build/test/"));
});
注意:我使用了兩個分離的``tsc.createProject``,因爲在不同的輸入和輸出文件夾中使用相同的兩次會導致意外的行爲。
完整的示例可here。看看gulpfile.js
文件。
你能再細說一下嗎? '你需要知道'是什麼意思?也許[這](https://medium.com/@mweststrate/how-to-create-strongly-typed-npm-modules-1e1bda23a7f4#.1b6jcuj4r)是一個有用的職位。 – Rik