2016-11-30 46 views
0

我試圖運行一個吞噬任務來編譯我的打字稿,但不斷得到與依存關係有關的錯誤。排除node_modules表單打字稿通過gulp-typescript編譯

/content/node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2304: Cannot find name 'Map'. 
/content/node_modules/@angular/core/src/facade/lang.d.ts(13,17): error TS2304: Cannot find name 'Set'. 

我想省略node_modules目錄,以便它只會通知我在我的代碼中的問題。我的文件如下:

gulpfile.js

var tsProject = ts.createProject('tsconfig.json'); 
gulp.task('ts', function() { 
    return gulp.src([aemPaths.jcrRoot + '**/*.ts']) 
     .pipe(tsProject()) 
     .pipe(gulp.dest(aemPaths.jcrRoot)); 
}); 

我也試過

gulp.task('ts', function() { 
    return gulp.src([aemPaths.jcrRoot + '**/*.ts','!node_modules/**/*']) 
     .pipe(tsProject()) 
     .pipe(gulp.dest(aemPaths.jcrRoot)); 
}); 

tsconfig.json

{ 
    "compilerOptions": { 
     "target": "es5", 
     "module": "commonjs", 
     "moduleResolution": "node", 
     "sourceMap": false, 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "removeComments": false, 
     "noImplicitAny": false, 
     "suppressImplicitAnyIndexErrors": true 
    }, 
    "exclude": [ 
     "node_modules" 
    ] 
} 

我已經做了很多的搜索,但可以似乎沒有找到一個方法來省略這個與吞噬打字稿。任何幫助將不勝感激。

回答

0

你不需要exlude node_modules目錄到一飲而盡,只需加分型ES6的集合和ES6,承諾到gulp.src陣列

+0

原諒我,如果我錯過的理解,因爲這是大家很新的給我。我繼續並安裝了以下內容:'npm install --save-dev es6-promise es6-collections'但在編譯時仍然會出現相同的打印錯誤。 – kisonay

+0

@kisonay 使用'npm install typings'命令。 安裝實際類型: 'typings install es6-collections'; 'typings install es6-promise'; 然後,進入目錄類型,你會發現index.d.ts。您需要將此文件包含在您的gulp.src中 – Navvygator