TypeScript - deprecation warning 'createNodeArray'

358 Views Asked by At

I am currently updating an Angular project to the newest stable version (Angular V16). While doing that I have to uptade the "typescript" version as well. If I update the ts version to 5.x.x and run npm run -s tslint then I get following error TypeError: ts.createNodeArray is not a function.

But when I downgrade the ts version to 4.x.x then the error becomes a deprecation warning.

DeprecationWarning: 'createNodeArray' has been deprecated since v4.0.0. Use the appropriate method on 'ts.factory' or the 'factory' supplied by your transformation context instead.

Now to the question - What changes need to be made to remove the deprecation warning?

Below you can see the package.json and tslint.json file

package.json

  "dependencies": {
    "@angular/animations": "16.2.8",
    "@angular/cdk": "16.2.7",
    "@angular/common": "16.2.8",
    "@angular/compiler": "16.2.8",
    "@angular/core": "16.2.8",
    "@angular/forms": "16.2.8",
    "@angular/localize": "16.2.8",
    "@angular/material": "16.2.7",
    "@angular/material-moment-adapter": "16.2.7",
    "@angular/platform-browser": "16.2.8",
    "@angular/platform-browser-dynamic": "16.2.8",
    "@angular/platform-server": "16.2.8",
    "@angular/router": "16.2.8",
    "@stomp/stompjs": "7.0.0",
    "core-js": "3.33.0",
    "diff-match-patch-ts": "0.3.0",
    "jquery": "3.7.1",
    "lodash": "4.17.21",
    "moment": "2.29.4",
    "net": "1.0.2",
    "ngx-diff": "5.0.0",
    "ngx-image-zoom": "2.1.0",
    "rxjs": "7.8.1",
    "sockjs-client": "1.6.1",
    "stompjs": "2.3.3",
    "zone.js": "0.13.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "16.2.5",
    "@angular/cli": "16.2.5",
    "@angular/compiler-cli": "16.2.8",
    "@angular/language-service": "16.2.8",
    "@types/jasmine": "5.1.0",
    "@types/lodash": "4.14.199",
    "@types/node": "18.16.17",
    "codelyzer": "6.0.2",
    "jasmine-core": "5.1.1",
    "jasmine-spec-reporter": "7.0.0",
    "karma": "6.4.2",
    "karma-chrome-launcher": "3.2.0",
    "karma-cli": "2.0.0",
    "karma-coverage-istanbul-reporter": "3.0.3",
    "karma-jasmine": "5.1.0",
    "protractor": "7.0.0",
    "sass-lint": "1.13.1",
    "ts-node": "10.9.1",
    "tslint": "6.1.3",
    "typescript": "4.9.5"
  }

tslint.json

"rulesDirectory": [
    "node_modules/codelyzer"
  ],
  "rules": {
    "arrow-return-shorthand": true,
    "callable-types": true,
    "class-name": true,
    "comment-format": [
      true,
      "check-space"
    ],
    "curly": true,
//    "deprecation": {
//      "severity": "warn"
//    },
    "eofline": true,
    "forin": true,
    "import-blacklist": [
      true,
      "rxjs/Rx"
    ],
    "import-spacing": true,
    "indent": [
      true,
      "spaces"
    ],
    "interface-over-type-literal": true,
    "label-position": true,
    "max-line-length": [
      true,
      200
    ],
    "member-access": false,
    "member-ordering": [
      true,
      {
        "order": [
          "static-field",
          "instance-field",
          "static-method",
          "instance-method"
        ]
      }
    ],
    "no-arg": true,
    "no-bitwise": true,
    "no-console": [
      true,
      "debug",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-construct": true,
    "no-debugger": true,
    "no-duplicate-super": true,
    "no-empty": false,
    "no-empty-interface": true,
    "no-eval": true,
    "no-inferrable-types": [
      true,
      "ignore-params"
    ],
    "no-misused-new": true,
    "no-non-null-assertion": true,
    "no-shadowed-variable": true,
    "no-string-literal": false,
    "no-string-throw": true,
    "no-switch-case-fall-through": true,
    "no-trailing-whitespace": true,
    "no-unnecessary-initializer": true,
    "no-unused-expression": true,
    "no-var-keyword": true,
    "object-literal-sort-keys": false,
    "one-line": [
      true,
      "check-open-brace",
      "check-catch",
      "check-else",
      "check-whitespace"
    ],
    "prefer-const": true,
    "quotemark": [
      false,
      "single"
    ],
    "radix": true,
    "semicolon": [
      true,
      "always"
    ],
    "triple-equals": [
      true,
      "allow-null-check"
    ],
    "typedef-whitespace": [
      true,
      {
        "call-signature": "nospace",
        "index-signature": "nospace",
        "parameter": "nospace",
        "property-declaration": "nospace",
        "variable-declaration": "nospace"
      }
    ],
    "unified-signatures": true,
    "variable-name": false,
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-separator",
      "check-type"
    ],
    "directive-selector": [
      true,
      "attribute",
      "camelCase"
    ],
    "component-selector": [
      true,
      "element",
      "kebab-case"
    ],
    "no-output-on-prefix": true,
    "no-inputs-metadata-property": true,
    "no-outputs-metadata-property": true,
    "no-host-metadata-property": true,
    "no-input-rename": true,
    "no-output-rename": true,
    "use-lifecycle-interface": true,
    "use-pipe-transform-interface": true,
    "component-class-suffix": true,
    "directive-class-suffix": true
  }
0

There are 0 best solutions below