[英]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.