I recently came across a file from a tutorial that has left me confused due to the inconsistency between documentation, tutorials, and examples:
/scripts/tsconfig.json:
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"noEmitOnError": true,
"noImplicitAny": false,
"outDir": "../wwwroot/appScripts/",
"removeComments": false,
"sourceMap": true,
"target": "es5",
"moduleResolution": "node"
},
"exclude": [
"node_modules",
"typings/index",
"typings/index.d.ts"
]
}
Although the options are configured for compilation on save, I am experiencing an issue where the JavaScript output ends up either beneath or attached to the source file:
TypeScript
|
--test.ts
|
--test.js
This creates a cluttered directory structure within /TypeScript
. Strangely enough, even though the tsconfig.json
file is present, the compiler seems to be ignoring the
"outDir": "../wwwroot/appScripts/"
setting.
While I am still new to Gulp, the Gulp task setup appears correct to me:
var tsProject = ts.createProject('scripts/tsconfig.json');
gulp.task('ts', function (done) {
//var tsResult = tsProject.src()
var tsResult = gulp.src([
"scripts/*.ts"
])
.pipe(ts(tsProject), undefined, ts.reporter.fullReporter());
return tsResult.js.pipe(gulp.dest('./wwwroot/appScripts'));
});