【问题标题】:Gulp typescript compiling files that I'm not specifying?Gulp typescript 编译我没有指定的文件?
【发布时间】:2017-04-30 19:40:11
【问题描述】:

我的意图是在src/main/ts/ 的(以及任何子目录)中编译*.ts 文件位置。我有tsconfig.json 文件,看起来像这样:

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

我的 gulp 任务如下所示:

    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"));
    });

src/main/ts/ 中的一些文件存在编译问题,因此我将这些文件移至项目根目录中名为 temp 的目录。

但是 gulp 任务也会编译 temp 中的文件。我收到如下错误:

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

想法?

【问题讨论】:

  • 您在 order.ts 中缺少导入。请在 order.ts 中提供代码

标签: typescript gulp gulp-typescript


【解决方案1】:

根据 the tsconfig.json documentation,你应该使用"include"(如果需要,"exclude")来指定要编译的文件,而不是"filesGlob"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-30
    • 1970-01-01
    • 1970-01-01
    • 2021-03-04
    • 1970-01-01
    • 2014-11-24
    • 1970-01-01
    • 2016-12-18
    相关资源
    最近更新 更多