0

Got an exception when building my Angular project. This a project which has not been changed in a while and gets build everyday by Jenkins. Today it has started to fail and I can't really work out why.

ERROR in [at-loader] ./node_modules/@types/estree/index.d.ts:107:38 TS2304: Cannot find name 'Omit'.

My package.json has the following dependencies:

"dependencies": {
    "@angular/animations": "^7.2.6",
    "@angular/cdk": "^7.3.3",
    "@angular/compiler": "^7.2.6",
    "@angular/compiler-cli": "7.2.6",
    "@angular/core": "^7.2.6",
    "@angular/forms": "^7.2.6",
    "@angular/http": "^7.2.6",
    "@angular/material": "^7.3.3",
    "@angular/platform-browser": "^7.2.6",
    "@angular/platform-browser-dynamic": "^7.2.6",
    "@angular/platform-server": "~7.2.6",
    "@angular/router": "^7.2.6",
    "@angular/tsc-wrapped": "~4.4.6",
    "@angular/upgrade": "~7.2.6",
    "angular-webstorage-service": "^1.0.2",
    "core-js": "^2.5.5",
    "npm": "^6.2.0",
    "rxjs-compat": "^6.4.0",
    "systemjs": "3.0.0",
    "tslib": "^1.9.0",
    "webpack-dev-server": "^3.8.1",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "^7.3.2",
    "@angular/common": "^7.2.6",
    "@angular/language-service": "^7.2.6",
    "@reactivex/rxjs": "^6.2.2",
    "@types/angular": "^1.6.49",
    "@types/angular-animate": "^1.5.10",
    "@types/angular-cookies": "^1.4.2",
    "@types/angular-mocks": "^1.6.1",
    "@types/angular-resource": "^1.5.6",
    "@types/angular-route": "^1.3.5",
    "@types/angular-sanitize": "^1.3.7",
    "@types/jasmine": "~3.3.9",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "^11.9.4",
    "angular2-template-loader": "^0.6.0",
    "awesome-typescript-loader": "^5.2.1",
    "babel-cli": "^6.16.0",
    "babel-preset-angular2": "^0.0.2",
    "babel-preset-es2015": "^6.16.0",
    "canonical-path": "1.0.0",
    "concurrently": "^4.1.0",
    "css-loader": "^2.1.0",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "file-loader": "^3.0.1",
    "html-loader": "^0.5.5",
    "html-webpack-plugin": "^3.2.0",
    "http-server": "^0.11.1",
    "jasmine": "~3.3.1",
    "jasmine-core": "~3.3.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-cli": "~2.0.0",
    "karma-coverage-istanbul-reporter": "^2.0.5",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "^3.0.5",
    "lite-server": "^2.4.0",
    "lodash": "^4.17.10",
    "null-loader": "^0.1.1",
    "phantomjs-prebuilt": "^2.1.16",
    "protractor": "^5.4.0",
    "raw-loader": "^1.0.0",
    "rimraf": "^2.5.4",
    "rollup": "^1.2.2",
    "rollup-plugin-commonjs": "^9.2.0",
    "rollup-plugin-node-resolve": "4.0.0",
    "rollup-plugin-uglify": "^6.0.2",
    "rxjs": "^6.4.0",
    "source-map-explorer": "^1.3.2",
    "style-loader": "^0.23.1",
    "ts-node": "~8.0.2",
    "tslint": "~5.12.1",
    "typescript": "3.3.3",
    "webpack": "^4.29.5",
    "webpack-cli": "^3.3.9",
    "webpack-merge": "^4.2.1"
  }

tslint.json

{
  "rules": {
    "class-name": true,
    "comment-format": [
      false,
      "check-space"
    ],
    "curly": true,
    "eofline": false,
    "forin": true,
    "indent": [
      false,
      "spaces"
    ],
    "label-position": true,
    "label-undefined": true,
    "max-line-length": [
      false,
      140
    ],
    "member-access": false,
    "member-ordering": [
      true,
      "static-before-instance",
      "variables-before-functions"
    ],
    "no-arg": true,
    "no-bitwise": true,
    "no-console": [
      true,
      "debug",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-construct": true,
    "no-debugger": true,
    "no-duplicate-key": true,
    "no-duplicate-variable": true,
    "no-empty": false,
    "no-eval": true,
    "no-inferrable-types": true,
    "no-shadowed-variable": true,
    "no-string-literal": false,
    "no-switch-case-fall-through": true,
    "no-trailing-whitespace": false,
    "no-unused-expression": true,
    "no-unused-variable": true,
    "no-unreachable": true,
    "no-use-before-declare": true,
    "no-var-keyword": true,
    "object-literal-sort-keys": false,
    "one-line": [
      false,
      "check-open-brace",
      "check-catch",
      "check-else",
      "check-whitespace"
    ],
    "quotemark": [
      false,
      "single"
    ],
    "radix": true,
    "semicolon": [
      false,
      "always"
    ],
    "triple-equals": [
      true,
      "allow-null-check"
    ],
    "typedef-whitespace": [
      true,
      {
        "call-signature": "nospace",
        "index-signature": "nospace",
        "parameter": "nospace",
        "property-declaration": "nospace",
        "variable-declaration": "nospace"
      }
    ],
    "variable-name": false,
    "whitespace": [
      false,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-separator",
      "check-type"
    ],
    "skipLibCheck": true
  }
}

Any ideas?

Thanks

Aisatora
  • 444
  • 6
  • 17
  • 5
    Your package manifest specifies the TypeScript version at `3.3.3`. `Omit` was added in TypeScript `3.5` ([reference](https://devblogs.microsoft.com/typescript/announcing-typescript-3-5/#the-omit-helper-type)). – Wing Feb 23 '22 at 11:49
  • but does it mean that some of my external dependencies are now using Omit? As I said my source has not been modified. – Aisatora Feb 23 '22 at 12:23
  • 1
    Yes, the error location says `./node_modules/@types/estree/index.d.ts`. Looking at the commit history for `@types/estree`, [`456c12a`](https://github.com/DefinitelyTyped/DefinitelyTyped/commit/465c12accc35d28d836e1f8427a3ed521ff249e6#diff-16f2152a186e70a58b85e709c86ca46bbbf1f6d19e2d3958d2b89c34f37a54cbR107) is the commit that introduced the usage of `Omit`. This was committed 17 days ago (from the time of this comment). – Wing Feb 23 '22 at 13:21
  • Voting to close this as a duplicate of [Cannot find name 'Omit' in Typescript](https://stackoverflow.com/questions/56440272/cannot-find-name-omit-in-typescript). – Wing Feb 23 '22 at 13:22

1 Answers1

1

Finally I narrowed down the problematic dependency

It was "rollup": "^1.2.2",

It was adding estree types which has been upgraded recently (check previous comments to my question) to use Omit type then since I am using an old version of Typescript which does not have the type it won't compile.

As a quick fix I have changed ^1.2.2 for ~1.2.2 to just accept future patch upgrades and it fixes the problem.

For reference, I have used the folowing command to figure this out:

npm ls @types/estree which tells you the "parent" dependency which added it.

Thanks

Aisatora
  • 444
  • 6
  • 17