Search code examples
angulartypescripttslint

Tslint error: The 'prefer-inline-decorator' rule threw an error: TypeError: Cannot read property 'kind' of undefined


After an Angular 9 upgrade, encountered the following error in the project:

Running ng lint throws the following error for every single .ts file in my app:

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 --version:

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

package.json:

{
  "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": {}
}

I could not find any instruction about this error. Removing the said rule in tslint.json file fix the issue, but skipping this is not an option due to the central codestyle ruleset of my company.

ng build, ng serve works fine, and using the app seems to be unaffected by this problem. Only the linter throws this error.


Solution

  • Solved:

    1. rm -rf node_modules/
    2. rm package-lock.json
    3. npm i

    Strangely enough, simple npm install˙and rm -rf node_modules/ was not enough, I had to delete the package lock file as well.