gulp-typescript在保存时发出错误,但随后的保存很好

twi*_*ams 4 typescript gulp angular

我不确定这是一个gulp问题,打字稿问题还是Angular 2问题.

我目前正在使用Angular 2 Beta 6.

这是我的打字稿gulp任务.

var tsProject = p.typescript.createProject("tsconfig.json");

gulp.task("client-scripts", function () {
    return gulp.src(paths.client.root + "**/*.ts")
        .pipe(p.cached("client-scripts"))
        .pipe(p.typescript(tsProject))
        .pipe(gulp.dest(paths.webroot.root));
});
Run Code Online (Sandbox Code Playgroud)

这是我的tsconfig文件.

{
  "compilerOptions": {
    "noImplicitAny": true,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": false,
    "target": "es5",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "moduleResolution": "node"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}
Run Code Online (Sandbox Code Playgroud)

我的Angular 2引导程序文件,其中包含角度测试版6所需的一些类型.我认为这是问题可能发生的一个领域.

///<reference path="../../node_modules/angular2/typings/browser.d.ts"/>
///<reference path="../../typings/shim.d.ts"/>

import { bootstrap } from "angular2/platform/browser";
import { ROUTER_PROVIDERS } from "angular2/router";
import { HTTP_PROVIDERS } from "angular2/http";
import { DataPlatformComponent } from "./dataPlatform.component";
import "rxjs/add/operator/map";

bootstrap(DataPlatformComponent, [ROUTER_PROVIDERS, HTTP_PROVIDERS]);
Run Code Online (Sandbox Code Playgroud)

该shim文件仅包含模块变量的声明,作为解决方案中的模块属性的角度6的问题的解决方法@component.我不知道它是否是一个原因,但顶部的那些引用只在boot.ts文件中,而不是我保存的任何其他后续ts文件.

在我的gulp构建过程的初始运行一切都是桃子...

[08:41:28] Starting 'entry'...
[08:41:28] Starting 'cleanup'...
[08:41:28] Finished 'entry' after 2.82 ms
[08:41:28] Finished 'cleanup' after 74 ms
[08:41:28] Starting 'initialize'...
[08:41:28] Starting 'vendor-scripts'...
[08:41:28] Starting 'vendor-content'...
[08:41:28] Starting 'client-scripts'...
[08:41:28] Starting 'client-nonscripts'...
[08:41:28] Starting 'client-sass'...
[08:41:28] Finished 'initialize' after 21 ms
[08:41:28] Finished 'vendor-scripts' after 176 ms
[08:41:28] Finished 'vendor-content' after 185 ms
[08:41:28] Finished 'client-sass' after 235 ms
[08:41:30] Finished 'client-scripts' after 2.31 s
[08:41:30] Finished 'client-nonscripts' after 2.3 s
Run Code Online (Sandbox Code Playgroud)

但是,如果我进入我的一个打字稿文件,并进行有效的更改或只是改变这样的空白......

export class DataPlatformComponent {
}
Run Code Online (Sandbox Code Playgroud)

对此

export class DataPlatformComponent {

}
Run Code Online (Sandbox Code Playgroud)

我在gulp输出窗口中收到了大量错误.以下两个列表仅为片段.

[08:59:08] Starting 'client-scripts'...
C:/Github/Data-Platform/src/DataPlatform/client/platform/dashboard/dashboard.component.ts(4,15): error TS2304: Cannot find name 'module'.
client\platform\dataplatform.component.ts(8,15): error TS2304: Cannot find name 'module'.
[08:59:10] TypeScript: 62 semantic errors
C:/Github/Data-Platform/src/DataPlatform/client/platform/report catalog/details/chip.component.ts(6,15): error TS2304: Cannot find name 'module'.
C:/Github/Data-Platform/src/DataPlatform/client/platform/report catalog/details/reportDetails.component.ts(7,15): error TS2304: Cannot find name 'module'.
[08:59:10] TypeScript: emit failed
C:/Github/Data-Platform/src/DataPlatform/client/platform/report catalog/main/navigation.component.ts(8,15): error TS2304: Cannot find name 'module'.
Run Code Online (Sandbox Code Playgroud)

主要是那些模块错误投诉和rxjs投诉.

[08:59:10] Finished 'client-scripts' after 2.08 s
C:/Github/Data-Platform/src/DataPlatform/client/platform/shell/navigation.component.ts(7,15): error TS2304: Cannot find name 'module'.
C:/Github/Data-Platform/src/DataPlatform/node_modules/angular2/src/core/change_detection/parser/locals.d.ts(3,14): error TS2304: Cannot find name 'Map'.
C:/Github/Data-Platform/src/DataPlatform/node_modules/angular2/src/core/change_detection/parser/locals.d.ts(4,42): error TS2304: Cannot find name 'Map'.
C:/Github/Data-Platform/src/DataPlatform/node_modules/angular2/src/core/debug/debug_node.d.ts(14,13): error TS2304: Cannot find name 'Map'.
C:/Github/Data-Platform/src/DataPlatform/node_modules/angular2/src/core/debug/debug_node.d.ts(24,17): error TS2304: Cannot find name 'Map'.
Run Code Online (Sandbox Code Playgroud)

如果我再次保存文件,一切都很好......但它似乎已经中断我的文件发出,所以我必须重新启动整个构建过程.

[09:02:50] Starting 'client-scripts'...
[09:02:51] Finished 'client-scripts' after 1.28 s
Run Code Online (Sandbox Code Playgroud)

根据要求,这是我的目录结构...我认为大多数文件都是不必要的.

|-DataPlatform
    |-wwwroot
    |-client
        |-platform
            |-content
            |-dashboard
            |-report catalog
            |-shared
            |-shell
            boot.ts
            dataPlatform.component.ts
            dataPlatform.template.html
        index.html
    |-node_modules
    |-typings
        shim.d.ts
    gulpfile.js
    package.json
    project.json
    tsconfig.json
    Startup.cs
Run Code Online (Sandbox Code Playgroud)

Gün*_*uer 6

/// <reference path="node_modules/angular2/typings/browser.d.ts" />
Run Code Online (Sandbox Code Playgroud)

在主TS文件中.

另见https://github.com/angular/angular/issues/7280#issuecomment-188777966