Angular Tslint错误';首选内联装饰器';规则引发错误:TypeError:无法读取属性';种类';未定义的
Angular 9升级后,在项目中遇到以下错误: 运行Angular Tslint错误';首选内联装饰器';规则引发错误:TypeError:无法读取属性';种类';未定义的,angular,typescript,tslint,Angular,Typescript,Tslint,Angular 9升级后,在项目中遇到以下错误: 运行ng lint会对我的应用程序中的每个.ts文件抛出以下错误: The 'prefer-inline-decorator' rule threw an error in '/path/to/my/project/src/app/app.component.ts': TypeError: Cannot read property 'kind' of undefined at Object.isParameterPropertyDecla
ng lint
会对我的应用程序中的每个.ts文件抛出以下错误:
The 'prefer-inline-decorator' rule threw an error in '/path/to/my/project/src/app/app.component.ts':
TypeError: Cannot read property 'kind' of undefined
at Object.isParameterPropertyDeclaration (/path/to/my/project/node_modules/typescript/lib/typescript.js:14561:83)
at callbackHandler (/path/to/my/project/node_modules/codelyzer/preferInlineDecoratorRule.js:163:50)
at callback (/path/to/my/project/node_modules/codelyzer/preferInlineDecoratorRule.js:218:9)
at visitNodes (/path/to/my/project/node_modules/typescript/lib/typescript.js:17774:30)
at Object.forEachChild (/path/to/my/project/node_modules/typescript/lib/typescript.js:18080:21)
at callback (/path/to/my/project/node_modules/codelyzer/preferInlineDecoratorRule.js:219:22)
at visitNodes (/path/to/my/project/node_modules/typescript/lib/typescript.js:17774:30)
at Object.forEachChild (/path/to/my/project/node_modules/typescript/lib/typescript.js:18007:24)
at walk (/path/to/my/project/node_modules/codelyzer/preferInlineDecoratorRule.js:221:18)
at Rule.AbstractRule.applyWithFunction (/path/to/my/project/node_modules/tslint/lib/language/rule/abstractRule.js:39:9)
ng--版本
:
Angular CLI: 9.0.2
Node: 10.19.0
OS: linux x64
Angular: 9.0.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.2
@angular-devkit/build-angular 0.900.2
@angular-devkit/build-optimizer 0.900.2
@angular-devkit/build-webpack 0.900.2
@angular-devkit/core 9.0.2
@angular-devkit/schematics 9.0.2
@angular/cdk 9.0.0
@angular/cli 9.0.2
@angular/flex-layout 9.0.0-beta.29
@angular/material 9.0.0
@ngtools/webpack 9.0.2
@schematics/angular 9.0.2
@schematics/update 0.900.2
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
{
"name": "my-app",
...
"dependencies": {
"@ag-grid-community/angular": "^22.1.2",
"@ag-grid-community/core": "^22.1.1",
"@angular-devkit/build-angular": "~0.900.2",
"@angular/animations": "9.0.1",
"@angular/cdk": "^9.0.0",
"@angular/common": "9.0.1",
"@angular/compiler": "9.0.1",
"@angular/core": "9.0.1",
"@angular/flex-layout": "^9.0.0-beta.29",
"@angular/forms": "9.0.1",
"@angular/language-service": "9.0.1",
"@angular/localize": "^9.0.1",
"@angular/material": "^9.0.0",
"@angular/platform-browser": "^9.0.1",
"@angular/platform-browser-dynamic": "^9.0.1",
"@angular/router": "9.0.1",
"@mat-datetimepicker/core": "^4.0.1",
"@ngx-translate/core": "^12.1.1",
"@ngx-translate/http-loader": "^4.0.0",
"ag-grid-angular": "^22.1.1",
"ag-grid-community": "^22.1.1",
"angular2-uuid": "^1.1.1",
"bignumber.js": "^9.0.0",
"core-js": "^3.6.2",
"date-fns": "1.29.0",
"del": "2.2.2",
"js-sha512": "^0.8.0",
"lodash": "^4.17.15",
"lodash-es": "^4.17.15",
"material-design-icons": "3.0.1",
"moment": "^2.24.0",
"ngx-uploader": "^8.0.0",
"ngx-webstorage": "^5.0.0",
"node-sass": "^4.13.1",
"rxjs": "6.5.4",
"text-mask-core": "^5.1.2",
"tslib": "^1.10.0",
"web-animations-js": "^2.3.2",
"zone.js": "~0.10.2",
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@angular/cli": "^9.0.2",
"@angular/compiler-cli": "^9.0.1",
"@angularclass/hmr": "^2.1.3",
"@compodoc/compodoc": "^1.1.11",
"@types/jasmine": "2.5.45",
"@types/lodash": "^4.14.149",
"@types/node": "^12.11.1",
"@typescript-eslint/eslint-plugin": "^2.17.0",
"@typescript-eslint/eslint-plugin-tslint": "^2.17.0",
"@typescript-eslint/parser": "^2.17.0",
"angular-playground": "6.1.2",
"codelyzer": "^5.1.2",
"concurrently": "^5.0.2",
"cypress": "^3.8.2",
"eslint": "^6.1.0",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-angular": "^4.0.1",
"eslint-plugin-import": "^2.20.0",
"husky": "^3.1.0",
"jasmine-core": "^2.6.4",
"jasmine-spec-reporter": "4.1.1",
"json-server": "^0.15.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^2.0.0",
"karma-coverage": "^2.0.1",
"karma-coverage-istanbul-reporter": "^2.1.1",
"karma-firefox-launcher": "^1.3.0",
"karma-jasmine": "^3.0.3",
"karma-jasmine-html-reporter": "^1.5.1",
"karma-structured-json-reporter": "^1.0.1",
"prettier": "1.18.2",
"pretty-quick": "^2.0.1",
"protractor": "~5.4.2",
"start-server-and-test": "^1.10.7",
"ts-node": "~8.3.0",
"tslint": "^5.20",
"tslint-config-airbnb": "^5.11",
"tslint-config-prettier": "^1.18",
"tslint-consistent-codestyle": "^1.16",
"typescript": "3.7.5",
"webpack-bundle-analyzer": "^3.6.0"
},
"false": {}
}
package.json
:
Angular CLI: 9.0.2
Node: 10.19.0
OS: linux x64
Angular: 9.0.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.2
@angular-devkit/build-angular 0.900.2
@angular-devkit/build-optimizer 0.900.2
@angular-devkit/build-webpack 0.900.2
@angular-devkit/core 9.0.2
@angular-devkit/schematics 9.0.2
@angular/cdk 9.0.0
@angular/cli 9.0.2
@angular/flex-layout 9.0.0-beta.29
@angular/material 9.0.0
@ngtools/webpack 9.0.2
@schematics/angular 9.0.2
@schematics/update 0.900.2
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
{
"name": "my-app",
...
"dependencies": {
"@ag-grid-community/angular": "^22.1.2",
"@ag-grid-community/core": "^22.1.1",
"@angular-devkit/build-angular": "~0.900.2",
"@angular/animations": "9.0.1",
"@angular/cdk": "^9.0.0",
"@angular/common": "9.0.1",
"@angular/compiler": "9.0.1",
"@angular/core": "9.0.1",
"@angular/flex-layout": "^9.0.0-beta.29",
"@angular/forms": "9.0.1",
"@angular/language-service": "9.0.1",
"@angular/localize": "^9.0.1",
"@angular/material": "^9.0.0",
"@angular/platform-browser": "^9.0.1",
"@angular/platform-browser-dynamic": "^9.0.1",
"@angular/router": "9.0.1",
"@mat-datetimepicker/core": "^4.0.1",
"@ngx-translate/core": "^12.1.1",
"@ngx-translate/http-loader": "^4.0.0",
"ag-grid-angular": "^22.1.1",
"ag-grid-community": "^22.1.1",
"angular2-uuid": "^1.1.1",
"bignumber.js": "^9.0.0",
"core-js": "^3.6.2",
"date-fns": "1.29.0",
"del": "2.2.2",
"js-sha512": "^0.8.0",
"lodash": "^4.17.15",
"lodash-es": "^4.17.15",
"material-design-icons": "3.0.1",
"moment": "^2.24.0",
"ngx-uploader": "^8.0.0",
"ngx-webstorage": "^5.0.0",
"node-sass": "^4.13.1",
"rxjs": "6.5.4",
"text-mask-core": "^5.1.2",
"tslib": "^1.10.0",
"web-animations-js": "^2.3.2",
"zone.js": "~0.10.2",
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@angular/cli": "^9.0.2",
"@angular/compiler-cli": "^9.0.1",
"@angularclass/hmr": "^2.1.3",
"@compodoc/compodoc": "^1.1.11",
"@types/jasmine": "2.5.45",
"@types/lodash": "^4.14.149",
"@types/node": "^12.11.1",
"@typescript-eslint/eslint-plugin": "^2.17.0",
"@typescript-eslint/eslint-plugin-tslint": "^2.17.0",
"@typescript-eslint/parser": "^2.17.0",
"angular-playground": "6.1.2",
"codelyzer": "^5.1.2",
"concurrently": "^5.0.2",
"cypress": "^3.8.2",
"eslint": "^6.1.0",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-angular": "^4.0.1",
"eslint-plugin-import": "^2.20.0",
"husky": "^3.1.0",
"jasmine-core": "^2.6.4",
"jasmine-spec-reporter": "4.1.1",
"json-server": "^0.15.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^2.0.0",
"karma-coverage": "^2.0.1",
"karma-coverage-istanbul-reporter": "^2.1.1",
"karma-firefox-launcher": "^1.3.0",
"karma-jasmine": "^3.0.3",
"karma-jasmine-html-reporter": "^1.5.1",
"karma-structured-json-reporter": "^1.0.1",
"prettier": "1.18.2",
"pretty-quick": "^2.0.1",
"protractor": "~5.4.2",
"start-server-and-test": "^1.10.7",
"ts-node": "~8.3.0",
"tslint": "^5.20",
"tslint-config-airbnb": "^5.11",
"tslint-config-prettier": "^1.18",
"tslint-consistent-codestyle": "^1.16",
"typescript": "3.7.5",
"webpack-bundle-analyzer": "^3.6.0"
},
"false": {}
}
我找不到有关此错误的任何说明。删除tslint.json
文件中的上述规则可以解决此问题,但由于我公司的中心代码样式规则集,跳过此选项不是一个选项
ng build
,ng serve
工作正常,使用该应用程序似乎不受此问题的影响。只有过梁抛出此错误。已解决:
rm-rf节点\u模块/
rm package lock.json
npm i
npm安装
˙和rm-rf node_模块
是不够的,我还必须删除包锁文件