我有一个当前使用JIT配置的角度应用程序,它运行正常。我尝试将其配置为使用AOT(Ahead of time)编译。 这是我迄今为止的工作:
这是我的 tsconfig-aot.ts :
{
"compileOnSave": true,
"compilerOptions": {
"target": "es5",
"module": "es2015",
"lib": ["es7", "dom"],
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"files": [
"wwwroot/app/app.module.ts",
"wwwroot/app/main.ts"
],
"angularCompilerOptions": {
"genDir": "aot",
"skipMetadataEmit" : true
},
"exclude": [
"node_modules"
]
}
我的 package.json :
{
"name": "AppName",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/angular/angular.io/blob/master/LICENSE"
}
],
"dependencies": {
"@angular/common": "2.4.0",
"@angular/compiler": "2.4.0",
"@angular/compiler-cli": "^2.4.10",
"@angular/core": "2.4.0",
"@angular/forms": "2.4.0",
"@angular/http": "2.4.0",
"@angular/platform-browser": "2.4.0",
"@angular/platform-browser-dynamic": "2.4.0",
"@angular/platform-server": "^2.4.10",
"@angular/router": "3.0.0",
"@angular/upgrade": "2.4.0",
"angular-in-memory-web-api": "0.1.5",
"bootstrap": "3.3.7",
"font-awesome": "^4.7.0",
"ng2-pagination": "2.0.0",
"primeng": "^2.0.0-rc.3",
"reflect-metadata": "0.1.8",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.39",
"zone.js": "0.6.25"
},
"devDependencies": {
"@types/node": "7.0.7",
"concurrently": "3.0.0",
"gulp": "^3.9.1",
"lite-server": "2.2.2",
"typescript": "2.2.1",
"typings": "2.1.0"
}
}
我的 main.ts :
import { platformBrowser } from '@angular/platform-browser';
import { AppModuleNgFactory } from '../../aot/wwwroot/app/app.module.ngfactory';
const platform = platformBrowser();
platform.bootstrapModuleFactory(AppModuleNgFactory);
我的应用程序配置为与Gulp和SystemJS一起使用,并使用Visual Studio 2015。 我尝试用命令提示符编译它:
"node_modules/.bin/ngc" -p tsconfig-aot.json
该应用程序已成功编译,但在运行时,我在 typings \ globals \ node \ index.d.ts 和 node_modules \ @types \ node \中遇到大约200个错误index.d.ts 即可。错误代码:
TS2502:'BuffType'在其自己的类型注释中直接或间接引用。
TS2451:无法重新声明块范围变量'常量'。
TS2430:接口'ReadWriteStream'错误地扩展了接口'ReadableStream'。 属性“暂停”的类型是不兼容的。 输入'()=> ReadWriteStream'不能赋值为'{():ReadableStream; (): 这个; }”。 类型'ReadWriteStream'不能指定为'this'类型。
其他类似的: TS2420,TS2415,TS2403,TS2320,TS2309,TS2300
所有这些错误都在 typings \ globals \ node \ index.d.ts 和 node_modules \ @types \ node \ index.d.ts 中。有人请帮忙!
究竟是什么问题?是版本问题还是某些导入问题或某些配置不正确?