【问题标题】:TSConfig Unknown compiler option 'lib'TSConfig 未知编译器选项“lib”
【发布时间】:2019-10-07 11:48:44
【问题描述】:

我正在使用 typescript 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 构建它。

【问题讨论】:

    标签: angular typescript tsconfig


    【解决方案1】:

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

    【讨论】:

    • 哈哈是的。我太傻了。谢谢你指出这一点。这是一个艰难的星期一早上。
    【解决方案2】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 2021-12-29
      • 2018-05-27
      • 2021-07-14
      • 1970-01-01
      • 1970-01-01
      • 2017-01-11
      • 2018-11-21
      • 2017-03-17
      • 2021-06-09
      相关资源
      最近更新 更多