我使用gulp-typescript编译angular2应用程序 . 我收到以下错误 .
C:/src/Terminal.Web/src/Terminal.Web/node_modules/angular2/src/facade/async.d.ts(3,53):错误TS2307:找不到模块'@activex / rxjs / dist / cjs /接收” . C:/src/Terminal.Web/src/Terminal.Web/node_modules/angular2/src/facade/async.d.ts(4,25):错误TS2307:找不到模块'@activex / rxjs / dist / cjs / RX” . [12:18:32] TypeScript:4个语义错误C:/src/Terminal.Web/src/Terminal.Web/node_modules/angular2/src/facade/async.d.ts(5,22):错误TS2307:不能找到模块'@ reactivex / rxjs / dist / cjs / Operator' . C:/src/Terminal.Web/src/Terminal.Web/node_modules/angular2/src/facade/lang.d.ts(2,22):error TS2304:找不到名称'BrowserNodeGlobal' .
这是gulp的任务 .
paths.appJs = "app/**/*.ts";
paths.appNg2ComponentsJs = "ng2components/**/*.ts";
paths.appHtml = "app/**/*.html";
paths.appJsOut = paths.webroot + "app/";
paths.angualr2Typings = "node_modules/angular2/typings/";
gulp.task("compile-app-components", function () {
var tscResult = gulp.src([paths.appNg2ComponentsJs, paths.angualr2Typings + "**/*.d.ts"])
.pipe(tsc({
"target": "es5",
"module": "system",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"listFiles": true,
}));
return tscResult.js
.pipe(gulp.dest(paths.appJsOut));
});
2 回答
首先,不应将
.d.ts
定义文件添加到gulp构建任务中:而且,你需要写
.ts
脚本开头的行(即paths.appJs
中的那些行)必要时(TypeScript编译器会告诉您何时不知道标识符) .如果您使用JSPM,解决方案是将tsconfig移动到wwwroot
将以下行添加到wwwroot / tsconfig.json中,以便systemjs不会尝试加载源映射: