typescriptgulpgulp-typescript

Gulp typescript compiling files that I'm not specifying?


My intention is to compile *.ts files location in the (And any subdirectories) of src/main/ts/. I have tsconfig.json file that looks like this:

    {
        "filesGlob": [
            "src/main/ts/**/*.ts"
        ],
        "compilerOptions": {
            "experimentalDecorators": true,
            "noImplicitAny": true,
            "moduleResolution": "node",
            "target": "es6"
        }
    }

My gulp task looks like this:

    var gulp = require('gulp');
    var ts = require('gulp-typescript');
    var tsProject = ts.createProject("tsconfig.json");

    gulp.task('default', function() {
      return tsProject.src()
        .pipe(tsProject())
        .js.pipe(gulp.dest("target/main/js"));
    });

I was having a compilation issue with some of the files in src/main/ts/ so I moved these to a directory in the root of the project called temp.

However the gulp task compiles the files in temp as well. I get errors like these:

temp/main/ts/domain/Order.ts(11,11): error TS1146: Declaration expected.

Thoughts?


Solution

  • According to the tsconfig.json documentation, you should use "include" (and if needed, "exclude") to specify the files to compile, not "filesGlob"