TSConfig未知的编译器选项“ lib”

时间:2019-05-21 06:25:54

标签: angular typescript tsconfig

我要用打字稿1.8.10接管一个旧的angular 1项目。

但是我无法编译,并且不断向我扔:

Unknown compiler option 'lib'

如果我注释掉“ lib”行,那么我将面临大量其他错误,例如

 Property 'X' does not exist on type 'Y'

这是一个相当大的旧项目,我只希望它运行2周,所以由于时间轴的原因,重新编码对我来说不是一个选择。

我曾尝试更改许多版本的打字稿,但是对我来说,同样的问题也显示出来,我也尝试使用--noImplicitUseStrict进行构建,但这无济于事。

这是我的tsconfig.json和我的package.json

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
      "module": "commonjs",
      "target": "es5",
      "noImplicitUseStrict" : true,
      "lib": ["es2015", "dom"]
 },
  "exclude": [
      "bower_components",
      "node_modules",
      "typings"
  ]
}

{
  "name": "xxx",
  "version": "0.0.0",
  "dependencies": {
    "@types/jquery": "^3.3.29",
    "grunt": "^1.0.4",
    "grunt-cli": "^1.3.2",
    "gulp-awspublish": "^3.3.0",
    "gulp-s3-deploy": "^1.0.1",
    "moment": "^2.24.0",
    "npm": "^6.9.0",
    "socket.io-client": "^1.7.2"
  },
  "scripts": {
    "test": "gulp test"
  },
  "devDependencies": {
    "@angular/cli": "^7.3.3",
    "browser-sync": "^2.26.5",
    "browser-sync-spa": "~1.0.3",
    "chalk": "~1.1.1",
    "del": "~2.0.2",
    "eslint-plugin-angular": "~0.12.0",
    "estraverse": "~4.1.0",
    "gulp": "^3.9.1",
    "gulp-angular-templatecache": "~1.8.0",
    "gulp-autoprefixer": "~3.0.2",
    "gulp-awspublish": "^3.3.0",
    "gulp-cssnano": "~2.1.1",
    "gulp-eslint": "~1.0.0",
    "gulp-filter": "~3.0.1",
    "gulp-flatten": "~0.2.0",
    "gulp-htmlmin": "~1.3.0",
    "gulp-inject": "~3.0.0",
    "gulp-load-plugins": "~0.10.0",
    "gulp-protractor": "~2.1.0",
    "gulp-rename": "~1.2.2",
    "gulp-replace": "~0.5.4",
    "gulp-rev": "~6.0.1",
    "gulp-rev-replace": "~0.4.2",
    "gulp-s3-deploy": "^1.0.1",
    "gulp-sass": "~2.0.4",
    "gulp-size": "~2.0.0",
    "gulp-sourcemaps": "~1.6.0",
    "gulp-uglify": "~1.4.1",
    "gulp-useref": "^3.1.6",
    "gulp-util": "~3.0.6",
    "http-proxy-middleware": "^0.19.1",
    "karma": "~0.13.10",
    "karma-coverage": "~0.5.2",
    "karma-jasmine": "~0.3.6",
    "karma-ng-html2js-preprocessor": "~0.2.0",
    "karma-phantomjs-launcher": "~0.2.1",
    "karma-phantomjs-shim": "~1.2.0",
    "lodash": "~3.10.1",
    "main-bower-files": "^2.13.1",
    "ng-annotate-loader": "0.0.10",
    "phantomjs": "~1.9.18",
    "ts-loader": "~0.8.0",
    "tslint-loader": "~1.0.2",
    "typescript": "^1.8.10",
    "typings": "~0.7.9",
    "uglify-save-license": "~0.4.1",
    "webpack-stream": "~2.1.1",
    "wiredep": "~2.2.2"
  },
  "engines": {
    "node": ">=0.10.0"
  }
}

请给我一些建议。我正在使用Gulp构建它。

2 个答案:

答案 0 :(得分:1)

就我而言,我只是在 npm install 之前忘记了 npm build。它可能会帮助某人。

答案 1 :(得分:0)

lib是TypeScript 2的功能,正如您提到的,您正在使用1.8。您可以从tsconfig.json中删除该库,也可以尝试升级到较新的打字稿版本。

在我的package.json中,我正在使用以下开发依赖项:

"ts-loader": "^5.4.4",
"typescript": "^3.4.5",

但是,如果升级,您可能会发现打字稿中断。