我不太確定這是一個吞嚥問題,打字稿還是Angular 2問題。gulp-typescript在保存時發出錯誤,但隨後保存很好
我目前正在使用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("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引導程序文件,其中包括一些類型爲測試版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]);
即墊片文件僅包含一個模塊變量聲明,作爲一種解決方法,以一個問題在角6與上@component
裝飾器模塊屬性。我不知道這是否是一個原因,但是上面的引用只在boot.ts文件中,而不是我保存的任何其他後續ts文件。
在我一飲而盡構建過程中的一切初始運行是桃色...
[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
但是,如果我去到我的打字稿文件中的一個,並進行有效的改變或者僅僅是想從這個空白的變化。 ..
export class DataPlatformComponent {
}
這個
export class DataPlatformComponent {
}
我得到了我一口o一個巨大的錯誤列表輸出窗口。以下兩個列表僅爲片段。
[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
你可以檢查你使用的是什麼版本的打字稿的?它是最新的'gulp-typingcript'嗎? – martin
它是「吞食打字稿」:「2.10.0」,打字稿1.7.5。我剛剛更新爲2.11.0的gulp-typingcript和1.8.2的打字稿,問題仍然存在。 – twilliams
你還可以發佈你的目錄結構嗎? – martin