在 Angular 4 中尝试编译 AoT 时出错
Errors when attempting to compile AoT in Angular 4
当尝试 运行 "node_modules/.bin/ngc" -p tsconfig-aot.json 这是编译 AoT 应用程序的 NGC 命令时,我得到以下这些错误并且不明白为什么他们都被吐槽了
$ "node_modules/.bin/ngc" -p tsconfig-aot.json
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/app.component.ts:15:11: Parameter 'theme' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/navmenu.component.ts:14:11: Parameter 'theme' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.general.ts:135:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.general.ts:140:32: Parameter 'index' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.general.ts:199:10: Parameter 'type' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.general.ts:204:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.general.ts:241:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.custom.ts:39:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.custom.ts:93:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.dynamic.ts:47:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.dynamic.ts:122:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.dynamic.ts:156:18: Parameter 'selectedType' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.message.ts:39:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.message.ts:92:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.security.ts:28:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.security.ts:110:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.security.ts:140:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/admin.dashboard.component.ts:102:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/admin.dashboard.component.ts:119:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/user.dashboard.component.ts:71:64: Parameter 'a' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/user.dashboard.component.ts:71:67: Parameter 'b' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/save.dashboard.component.ts:134:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:191:43: Property 'newDashboard' is private and only accessible within class 'AdminDashboardComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:319:40: Property 'selectedDash' does not exist on type 'NewDashboardDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:323:39: Property 'pressSubmit' is private and only accessible within class 'NewDashboardDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:323:55: Property 'selectedDash' does not exist on type 'NewDashboardDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:358:39: Property 'pressSubmit' is private and only accessible within class 'NewDashboardDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:358:55: Property 'selectedDash' does not exist on type 'NewDashboardDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:389:32: Property 'selectedDash' does not exist on type 'NewDashboardDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:628:43: Property 'pressAddFields' is private and only accessible within class 'EditDashboardGeneralComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:693:43: Property 'pressAddStatic' is private and only accessible within class 'EditDashboardGeneralComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:943:40: Property 'newFieldName' does not exist on type 'AddDashFieldDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:947:39: Property 'pressSubmit' is private and only accessible within class 'AddDashFieldDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:947:55: Property 'newFieldName' does not exist on type 'AddDashFieldDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:1007:43: Property 'pressSubmit' is private and only accessible within class 'AddDashFieldDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:1007:59: Property 'newFieldName' does not exist on type 'AddDashFieldDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:1038:32: Property 'newFieldName' does not exist on type 'AddDashFieldDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.custom.ngfactory.ts:134:43: Property 'pressAdd' is private and only accessible within class 'EditDashboardCustomComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.custom.ngfactory.ts:150:43: Property 'pressDelete' is private and only accessible within class 'EditDashboardCustomComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.custom.ngfactory.ts:679:43: Property 'pressSubmit' is private and only accessible within class 'AddCustomDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.custom.ngfactory.ts:718:39: Property 'pressSubmit' is private and only accessible within class 'AddCustomDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:178:43: Property 'pressAdd' is private and only accessible within class 'EditDashboardDynamicComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:194:43: Property 'pressDelete' is private and only accessible within class 'EditDashboardDynamicComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:405:43: Property 'pressEditProperties' is private and only accessible within class 'EditDashboardDynamicComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:611:43: Property 'pressSubmit' is private and only accessible within class 'AddDynamicDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:648:39: Property 'pressSubmit' is private and only accessible within class 'AddDynamicDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:845:40: Property 'newEndpoint' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:954:40: Property 'newUsername' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1031:44: Property 'newPassword' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1152:64: Property 'newDashName' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1152:80: Property 'newDashType' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1177:64: Property 'newDashName' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1177:80: Property 'newDashType' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1207:36: Property 'newEndpoint' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1215:36: Property 'newUsername' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1219:36: Property 'newPassword' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:139:43: Property 'pressAdd' is private and only accessible within class 'EditDashboardMessageComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:155:43: Property 'pressDelete' is private and only accessible within class 'EditDashboardMessageComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:645:44: Property 'newMessageName' does not exist on type 'AddMessageDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:649:43: Property 'pressSubmit' is private and only accessible within class 'AddMessageDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:649:59: Property 'newMessageName' does not exist on type 'AddMessageDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:684:39: Property 'pressSubmit' is private and only accessible within class 'AddMessageDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:684:55: Property 'newMessageName' does not exist on type 'AddMessageDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:715:32: Property 'newMessageName' does not exist on type 'AddMessageDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:137:43: Property 'pressAddAdmin' is private and only accessible within class 'EditDashboardSecurityComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:153:43: Property 'pressDeleteAdmin' is private and only accessible within class 'EditDashboardSecurityComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:207:43: Property 'pressAddUser' is private and only accessible within class 'EditDashboardSecurityComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:223:43: Property 'pressDeleteUser' is private and only accessible within class 'EditDashboardSecurityComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:346:44: Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:350:43: Property 'pressSubmit' is private and only accessible within class 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:350:59: Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:387:39: Property 'pressSubmit' is private and only accessible within class 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:387:55: Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:420:32: Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:438:32: Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:548:44: Property 'newUser' does not exist on type 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:552:43: Property 'pressSubmit' is private and only accessible within class 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:552:59: Property 'newUser' does not exist on type 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:589:39: Property 'pressSubmit' is private and only accessible within class 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:589:55: Property 'newUser' does not exist on type 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:622:32: Property 'newUser' does not exist on type 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:640:32: Property 'newUser' does not exist on type 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/save.dashboard.component.ngfactory.ts:37:39: Property 'pressSave' is private and only accessible within class 'SaveDashboardComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/save.dashboard.component.ngfactory.ts:57:43: Property 'pressCancel' is private and only accessible within class 'SaveDashboardComponent'.
AoT 的相关文件
tsconfig-aot.json
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"../../node_modules/@types/"
]
},
"files": [
"src/app/app.module.ts",
"src/main.ts"
],
"angularCompilerOptions": {
"genDir": "aot",
"skipMetadataEmit": true
}
}
main.ts
import { enableProdMode } from '@angular/core';
import { platformBrowser } from '@angular/platform-browser';
import { AppModuleNgFactory } from '../aot/src/app/app.module.ngfactory';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
console.log('Running AOT compiled');
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
我想从 JIT 迁移到 AOT 以获得更快的加载时间,这样当我实施 Tree Shaking 时它会更有效,但我不知道如何处理这些错误。请帮助
运行 具有 ng run --prod
的应用程序将执行 tree-shaking,运行 应用程序使用 AOT 编译。
如果您对更多细节感兴趣,我发现他们的 wiki 非常有用。
ng-cli Wiki
哦,你当然也可以使用 ng build --prod
。
关于我建议你开始使用 TS Lint 的错误,因为你违反了一些打字稿规则,主要是关于在 class 之外使用私有属性,它们在隐式类型定义中声明(不声明类型,是的,甚至 any 类型)。
我强烈建议使用 JetBrains PHPStorm 或 WebStorm 作为您的编辑器,它们提供了一系列令人惊叹的工具,并且在其中启用 TS Lint 检查非常容易。
虽然它们不是免费的。
- 所有
Parameter '***' implicitly has an 'any' type.
在您的 tsconfig-aot.json 中,您要求 noImplicitAny
.
所以 Typescript 会告诉您何时声明变量而不指定类型。
- 所有
Property '***' is private and only accessible within class '***'.
这是因为您有模板 html 试图访问私有组件 属性。没有AOT编译,不吐槽,因为是JS,但是有了AOT,就是Typescript,所以检查隐私。
- 所有
Property '***' does not exist on type '***'.
一样,您在模板中访问了一些 Typescript 不存在的属性。也许你做了一些 JS 允许的魔法,但 Typescript 更严格。
当尝试 运行 "node_modules/.bin/ngc" -p tsconfig-aot.json 这是编译 AoT 应用程序的 NGC 命令时,我得到以下这些错误并且不明白为什么他们都被吐槽了
$ "node_modules/.bin/ngc" -p tsconfig-aot.json
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/app.component.ts:15:11: Parameter 'theme' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/navmenu.component.ts:14:11: Parameter 'theme' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.general.ts:135:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.general.ts:140:32: Parameter 'index' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.general.ts:199:10: Parameter 'type' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.general.ts:204:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.general.ts:241:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.custom.ts:39:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.custom.ts:93:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.dynamic.ts:47:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.dynamic.ts:122:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.dynamic.ts:156:18: Parameter 'selectedType' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.message.ts:39:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.message.ts:92:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.security.ts:28:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.security.ts:110:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/edit.dashboard.security.ts:140:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/admin.dashboard.component.ts:102:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/admin.dashboard.component.ts:119:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/user.dashboard.component.ts:71:64: Parameter 'a' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/user.dashboard.component.ts:71:67: Parameter 'b' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/save.dashboard.component.ts:134:23: Parameter 'message' implicitly has an 'any' type.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:191:43: Property 'newDashboard' is private and only accessible within class 'AdminDashboardComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:319:40: Property 'selectedDash' does not exist on type 'NewDashboardDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:323:39: Property 'pressSubmit' is private and only accessible within class 'NewDashboardDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:323:55: Property 'selectedDash' does not exist on type 'NewDashboardDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:358:39: Property 'pressSubmit' is private and only accessible within class 'NewDashboardDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:358:55: Property 'selectedDash' does not exist on type 'NewDashboardDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/admin.dashboard.component.ngfactory.ts:389:32: Property 'selectedDash' does not exist on type 'NewDashboardDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:628:43: Property 'pressAddFields' is private and only accessible within class 'EditDashboardGeneralComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:693:43: Property 'pressAddStatic' is private and only accessible within class 'EditDashboardGeneralComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:943:40: Property 'newFieldName' does not exist on type 'AddDashFieldDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:947:39: Property 'pressSubmit' is private and only accessible within class 'AddDashFieldDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:947:55: Property 'newFieldName' does not exist on type 'AddDashFieldDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:1007:43: Property 'pressSubmit' is private and only accessible within class 'AddDashFieldDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:1007:59: Property 'newFieldName' does not exist on type 'AddDashFieldDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.general.ngfactory.ts:1038:32: Property 'newFieldName' does not exist on type 'AddDashFieldDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.custom.ngfactory.ts:134:43: Property 'pressAdd' is private and only accessible within class 'EditDashboardCustomComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.custom.ngfactory.ts:150:43: Property 'pressDelete' is private and only accessible within class 'EditDashboardCustomComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.custom.ngfactory.ts:679:43: Property 'pressSubmit' is private and only accessible within class 'AddCustomDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.custom.ngfactory.ts:718:39: Property 'pressSubmit' is private and only accessible within class 'AddCustomDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:178:43: Property 'pressAdd' is private and only accessible within class 'EditDashboardDynamicComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:194:43: Property 'pressDelete' is private and only accessible within class 'EditDashboardDynamicComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:405:43: Property 'pressEditProperties' is private and only accessible within class 'EditDashboardDynamicComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:611:43: Property 'pressSubmit' is private and only accessible within class 'AddDynamicDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:648:39: Property 'pressSubmit' is private and only accessible within class 'AddDynamicDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:845:40: Property 'newEndpoint' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:954:40: Property 'newUsername' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1031:44: Property 'newPassword' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1152:64: Property 'newDashName' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1152:80: Property 'newDashType' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1177:64: Property 'newDashName' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1177:80: Property 'newDashType' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1207:36: Property 'newEndpoint' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1215:36: Property 'newUsername' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.dynamic.ngfactory.ts:1219:36: Property 'newPassword' does not exist on type 'AddEditRestDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:139:43: Property 'pressAdd' is private and only accessible within class 'EditDashboardMessageComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:155:43: Property 'pressDelete' is private and only accessible within class 'EditDashboardMessageComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:645:44: Property 'newMessageName' does not exist on type 'AddMessageDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:649:43: Property 'pressSubmit' is private and only accessible within class 'AddMessageDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:649:59: Property 'newMessageName' does not exist on type 'AddMessageDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:684:39: Property 'pressSubmit' is private and only accessible within class 'AddMessageDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:684:55: Property 'newMessageName' does not exist on type 'AddMessageDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.message.ngfactory.ts:715:32: Property 'newMessageName' does not exist on type 'AddMessageDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:137:43: Property 'pressAddAdmin' is private and only accessible within class 'EditDashboardSecurityComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:153:43: Property 'pressDeleteAdmin' is private and only accessible within class 'EditDashboardSecurityComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:207:43: Property 'pressAddUser' is private and only accessible within class 'EditDashboardSecurityComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:223:43: Property 'pressDeleteUser' is private and only accessible within class 'EditDashboardSecurityComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:346:44: Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:350:43: Property 'pressSubmit' is private and only accessible within class 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:350:59: Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:387:39: Property 'pressSubmit' is private and only accessible within class 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:387:55: Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:420:32: Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:438:32: Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:548:44: Property 'newUser' does not exist on type 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:552:43: Property 'pressSubmit' is private and only accessible within class 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:552:59: Property 'newUser' does not exist on type 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:589:39: Property 'pressSubmit' is private and only accessible within class 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:589:55: Property 'newUser' does not exist on type 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:622:32: Property 'newUser' does not exist on type 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/edit.dashboard.security.ngfactory.ts:640:32: Property 'newUser' does not exist on type 'AddNotificationTwoDialog'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/save.dashboard.component.ngfactory.ts:37:39: Property 'pressSave' is private and only accessible within class 'SaveDashboardComponent'.
Error at C:/Users/DTurcich/Source/Repos/Interns/DashboardConsole/ASCI.DashboardConsole.Frontend/aot/src/app/save.dashboard.component.ngfactory.ts:57:43: Property 'pressCancel' is private and only accessible within class 'SaveDashboardComponent'.
AoT 的相关文件
tsconfig-aot.json
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"../../node_modules/@types/"
]
},
"files": [
"src/app/app.module.ts",
"src/main.ts"
],
"angularCompilerOptions": {
"genDir": "aot",
"skipMetadataEmit": true
}
}
main.ts
import { enableProdMode } from '@angular/core';
import { platformBrowser } from '@angular/platform-browser';
import { AppModuleNgFactory } from '../aot/src/app/app.module.ngfactory';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
console.log('Running AOT compiled');
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
我想从 JIT 迁移到 AOT 以获得更快的加载时间,这样当我实施 Tree Shaking 时它会更有效,但我不知道如何处理这些错误。请帮助
运行 具有 ng run --prod
的应用程序将执行 tree-shaking,运行 应用程序使用 AOT 编译。
如果您对更多细节感兴趣,我发现他们的 wiki 非常有用。
ng-cli Wiki
哦,你当然也可以使用 ng build --prod
。
关于我建议你开始使用 TS Lint 的错误,因为你违反了一些打字稿规则,主要是关于在 class 之外使用私有属性,它们在隐式类型定义中声明(不声明类型,是的,甚至 any 类型)。
我强烈建议使用 JetBrains PHPStorm 或 WebStorm 作为您的编辑器,它们提供了一系列令人惊叹的工具,并且在其中启用 TS Lint 检查非常容易。
虽然它们不是免费的。
- 所有
Parameter '***' implicitly has an 'any' type.
在您的 tsconfig-aot.json 中,您要求 noImplicitAny
.
所以 Typescript 会告诉您何时声明变量而不指定类型。
- 所有
Property '***' is private and only accessible within class '***'.
这是因为您有模板 html 试图访问私有组件 属性。没有AOT编译,不吐槽,因为是JS,但是有了AOT,就是Typescript,所以检查隐私。
- 所有
Property '***' does not exist on type '***'.
一样,您在模板中访问了一些 Typescript 不存在的属性。也许你做了一些 JS 允许的魔法,但 Typescript 更严格。