gulp typescript在保存时会发出错误,但在后续保存时可以
我不确定这是一个吞咽问题,一个打字问题还是一个角度2的问题 我目前正在使用Angular 2 Beta 6 这是我的打字脚本吞咽任务gulp typescript在保存时会发出错误,但在后续保存时可以,typescript,gulp,angular,Typescript,Gulp,Angular,我不确定这是一个吞咽问题,一个打字问题还是一个角度2的问题 我目前正在使用Angular 2 Beta 6 这是我的打字脚本吞咽任务 var tsProject = p.typescript.createProject("tsconfig.json"); gulp.task("client-scripts", function () { return gulp.src(paths.client.root + "**/*.ts") .pipe(p.cached("clie
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文件
{
"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所需的一些打字。我认为这是一个可能出现问题的领域
///<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]);
但是如果我进入我的一个typescript文件,做了一个有效的更改,或者仅仅是像这样的空白更改
export class DataPlatformComponent {
}
对此
export class DataPlatformComponent {
}
在我的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'.
主要是模块错误投诉和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'.
如果我再次保存文件,一切都会好起来。。。但它似乎中断了我的文件发射,因此我必须重新启动整个构建过程
[09:02:50] Starting 'client-scripts'...
[09:02:51] Finished 'client-scripts' after 1.28 s
根据要求,这是我的目录结构。。。我认为大多数文件都是不必要的
|-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
加
//
在主TS文件中
另请参见是否可以检查您使用的typescript版本?它是最新的
gulptypescript
?它是“gulptypescript”:“2.10.0”,带有typescript 1.7.5。我刚刚更新到gulp typescript 2.11.0和typescript 1.8.2,问题仍然存在。你能发布你的目录结构吗?请查看底部的编辑。一切看起来都很好,顺便问一下你的npm
版本是什么?如果<3.0,请尝试升级,然后删除node\u modules
目录并重新安装。从3.0版开始,它尝试安装依赖项平面,因此它可能与此相关。请看,我已经完成了此操作。它适用于主TS文件,但所有后续文件在进行更改时都会继续抛出错误。。。我必须将该引用添加到每个TS文件中,它才能工作。这可能会有所帮助
|-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
/// <reference path="node_modules/angular2/typings/browser.d.ts" />