我有一个简单的gulp文件,它编译TS并将它们放在dist文件夹中。
我使用node v6.2.0和tsc v1.8.10。
一切都很好,但是我得到了很多错误:
node_modules \ @angular \共同\ ESM \ SRC \指令\ ng_for.d.ts(7,14): 错误TS1005:' ='预期。 node_modules \ @angular \共同\ ESM \ SRC \指令\ ng_for.d.ts(7,19): 错误TS1005:';'预期。 node_modules \ @angular \共同\ ESM \ SRC \指令\ ng_for.d.ts(8,14): 错误TS1005:' ='预期。 node_modules \ @angular \共同\ ESM \ SRC \指令\ ng_for.d.ts(8,18): 错误TS1005:';'预期。 node_modules \ @angular \共同\ ESM \ SRC \指令\ ng_for.d.ts(9,14): 错误TS1005:' ='预期。 node_modules \ @angular \共同\ ESM \ SRC \指令\ ng_for.d.ts(9,18): 错误TS1005:';'预期。 node_modules \ @angular \共同\ ESM \ SRC \指令\ ng_for.d.ts(10,14): 错误TS1005:' ='预期。 node_modules \ @angular \共同\ ESM \ SRC \指令\ ng_for.d.ts(10,17): 错误TS1005:';'预期
tsconfig.json
{
"compilerOptions": {
"outDir": "dist/dashboard",
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules"
]
}
gulpfile.js
const gulp = require("gulp");
const del = require("del");
const tsc = require("gulp-typescript");
const sourcemaps = require('gulp-sourcemaps');
const tsProject = tsc.createProject("tsconfig.json");
const tslint = require('gulp-tslint');
const config = require('./gulp.config.js');
const $ = require('gulp-load-plugins')({
lazy: true
});
// clean the contents of the distribution directory
gulp.task('clean', function() {
return del(config.dest, { force: true });
});
gulp.task('resources', function() {
_log('copy - ' + config.assets, $.util.colors.yellow);
return gulp.src(config.assets, { base: config.root })
.pipe(gulp.dest(config.dest));
});
/**
* Copy all required libraries into build directory.
*/
gulp.task("libs", () => {
_log('copying libs to:' + config.dest + 'lib' ,$.util.colors.yellow);
return gulp.src([
'es6-shim/es6-shim.min.js',
'systemjs/dist/system-polyfills.js',
'systemjs/dist/system.src.js',
'reflect-metadata/Reflect.js',
'rxjs/**',
'zone.js/dist/**',
'@angular/**'
], { cwd: 'node_modules/**' })
.pipe(gulp.dest(config.dest + 'lib'));
});
/**
* Compile TypeScript sources and create sourcemaps in build directory.
*/
gulp.task("compile", () => {
var tsResult = gulp.src(config.root + "**/*.ts")
.pipe(sourcemaps.init())
.pipe(tsc(tsProject));
return tsResult.js
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(config.dest));
});
gulp.task("default", ['compile', 'resources', 'libs'], () => {
_log('Building the project ...', $.util.colors.yellow);
});
function _log(msg, color) {
color = color || $.util.colors.blue;
$.util.log(color(msg));
}
function _logError(error) {
_log('**** START OF ERROR ***', $.util.colors.red);
_log(error, $.util.colors.red);
_log('**** END OF ERROR ***', $.util.colors.red);
return error;
}
我如何摆脱这些错误?