[英]TS2304: Cannot find name 'Omit'
構建我的 Angular 項目時出現異常。 這是一個有一段時間沒有更改的項目,每天由 Jenkins 構建。今天它開始失敗,我真的不知道為什么。
[at-loader]./node_modules/@types/estree/index.d.ts:107:38 TS2304 中的錯誤:找不到名稱“Omit”。
我的 package.json 具有以下依賴項:
"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
}
}
有任何想法嗎?
謝謝
最后我縮小了有問題的依賴
這是“匯總”:“^1.2.2”,
它正在添加最近升級的 estree 類型(檢查我的問題之前的評論)以使用 Omit 類型,因為我使用的是舊版本的 Typescript,它沒有它不會編譯的類型。
作為快速修復,我將 ^1.2.2 更改為 ~1.2.2 以僅接受未來的補丁升級並解決了問題。
作為參考,我使用以下命令來解決這個問題:
npm ls @types/estree告訴您添加它的“父”依賴項。
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.