首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gulp-typescript在保存时发出错误,但在后续保存时没有问题

gulp-typescript在保存时发出错误,但在后续保存时没有问题
EN

Stack Overflow用户
提问于 2016-02-23 23:03:46
回答 1查看 10.1K关注 0票数 4

我真的不确定这是一个吞咽问题,一个打字问题还是一个Angular 2问题。

我目前使用的是Angular 2 Beta 6。

这是我的打字任务。

代码语言:javascript
复制
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));
});

这是我的tsconfig文件。

代码语言:javascript
复制
{
  "compilerOptions": {
    "noImplicitAny": true,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": false,
    "target": "es5",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "moduleResolution": "node"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

我的angular 2引导程序文件,其中包括Angular beta 6所需的一些类型。我认为这是一个可能发生问题的领域。

代码语言:javascript
复制
///<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]);

该填充文件仅包含模块变量的声明,作为angular 6中@component装饰器上的模块属性问题的变通方法。我不知道这是否可能是一个原因,但顶部的那些引用只在boot.ts文件上,而不是我保存的任何其他后续ts文件上。

在我最初运行的gulp构建过程中,一切都很完美……

代码语言:javascript
复制
[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

但是如果我进入我的一个typescript文件,并进行有效的更改,或者只是一个空格更改,就像这样……

代码语言:javascript
复制
export class DataPlatformComponent {
}

到这个

代码语言:javascript
复制
export class DataPlatformComponent {

}

在我的吞咽输出窗口中,我得到了一个巨大的错误列表。下面的两个列表仅仅是片断。

代码语言:javascript
复制
[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'.

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

代码语言:javascript
复制
[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'.

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

代码语言:javascript
复制
[09:02:50] Starting 'client-scripts'...
[09:02:51] Finished 'client-scripts' after 1.28 s

按照要求,这是我的目录结构...我认为大部分不必要的文件都被省略了。

代码语言:javascript
复制
|-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
EN

回答 1

Stack Overflow用户

发布于 2016-03-08 14:59:05

添加

代码语言:javascript
复制
/// <reference path="node_modules/angular2/typings/browser.d.ts" />

在主TS文件中。

另请参阅https://github.com/angular/angular/issues/7280#issuecomment-188777966

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35580944

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档