首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >tsc不忽略带有“skipLibCheck”的库文件: true

tsc不忽略带有“skipLibCheck”的库文件: true
EN

Stack Overflow用户
提问于 2022-03-19 19:04:46
回答 1查看 1.5K关注 0票数 1

对于这个项目,我有一个带有2个工作区(api和frontEnd)的monorepo。最近,我将节点从V10升级到V16,迁移几乎完成。我可以在本地运行,但是建筑已经不可能了。

当我将yarn workspace api start:dev (在api/pacage.json中定义为"start:dev": "cross-env NODE_ENV=development npx ts-node-dev -r dotenv/config -r tsconfig-paths/register --respawn --transpile-only src/index.ts" )运行时,它在本地主机上平稳地运行。

当我运行yarn workspace api build:ts (在api/pacage.json中定义为yarn run tsc )时,我得到以下类型的错误(为了遵守问题字符限制,我只保留了每个文件一个错误,但有超过2000行):

代码语言:javascript
复制
../node_modules/@types/babel__traverse/index.d.ts(68,50): error TS1005: ']' expected.
../node_modules/@types/express-serve-static-core/index.d.ts(99,68): error TS1110: Type expected.
../node_modules/@types/node/assert.d.ts(12,72): error TS1144: '{' or ';' expected.
../node_modules/@types/node/index.d.ts(72,1): error TS1084: Invalid 'reference' directive syntax.
../node_modules/@types/sinon/index.d.ts(30,54): error TS1005: ',' expected.
../node_modules/express-validator/src/chain/validators-impl.d.ts(79,27): error TS1005: ',' expected.
../node_modules/express-validator/src/chain/validators.d.ts(66,27): error TS1005: ',' expected.
../node_modules/express-validator/src/validation-result.d.ts(13,64): error TS1005: ',' expected.

这是我的api/tsconfig.json:

代码语言:javascript
复制
    {
      "compilerOptions": {
        "lib": ["es6"],
        "target": "es6",
        "module": "commonjs",
        "moduleResolution": "node",
        "outDir": "./build",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "sourceMap": true,
        "skipLibCheck": true,
        "baseUrl": "./src",
        "paths": {
          "@/*": ["./*"]
        }
      },
      "include": ["src/**/*"],
      "exclude": [
        "**/node_modules/*",
        "node_modules",
        "**/*.test.ts",
        "**/test/**/*"
      ]
    }

这是我的api/package.json:

代码语言:javascript
复制
    {
      "name": "api",
      "version": "3.8.18",
      "description": "",
      "license": "NONE",
      "private": true,
      "nohoist": [
        "**/express*",
        "**/express*/**"
      ],
      "engines": {},
      "scripts": {
        "build:ts": "yarn run tsc",
        "start": "yarn run start:prod",
        "start:prod": "cross-env NODE_ENV=production node -r ./tsconfig-paths-bootstrap.js build/index.js",
        "start:dev": "cross-env NODE_ENV=development npx ts-node-dev -r dotenv/config -r tsconfig-paths/register --respawn --transpile-only src/index.ts",
        "test": "cross-env  NODE_ENV=test mocha 'test/**/*.test.ts' --timeout 60000 --recursive --no-deprecation -r ts-node/register -r tsconfig-paths/register --file test/testUtils/test-setup.ts ",
        "test:unit": "yarn run test --grep @unit",
        "test:integration": "yarn run test --grep @int",
        "typeorm:cli": "ts-node -r tsconfig-paths/register ../node_modules/typeorm/cli -f ./src/ormconfig.ts",
        "migration:generate": "yarn run typeorm:cli migration:generate -n",
        "migration:create": "yarn run typeorm:cli migration:create -n",
        "migration:run": "yarn run typeorm:cli migration:run",
        "migration:revert": "yarn run typeorm:cli migration:revert",
        "migration:show": "yarn run typeorm:cli migration:show"
      },
      "devDependencies": {
        "@types/chai": "^4.3.0",
        "@types/chai-as-promised": "^7.1.4",
        "@types/cors": "^2.8.12",
        "@types/express": "^4.17.13",
        "@types/mocha": "^9.1.0",
        "@types/morgan": "^1.9.3",
        "@types/node": "^17.0.15",
        "@types/node-fetch": "^3.0.2",
        "@types/sinon": "^10.0.10",
        "@types/sinon-chai": "^3.2.8",
        "chai": "^4.3.6",
        "chai-as-promised": "^7.1.1",
        "dotenv": "^16.0.0",
        "mocha": "^9.2.0",
        "sinon": "^13.0.1",
        "sinon-chai": "^3.7.0",
        "sinon-express-mock": "^2.2.1",
        "supertest": "^6.2.2",
        "ts-node": "10.4.0",
        "ts-node-dev": "^1.1.8",
        "tsconfig-paths": "^3.12.0",
        "typescript": "^4.5.5"
      },
      "dependencies": {
        "@typescript-eslint/eslint-plugin": "^5.10.2",
        "@typescript-eslint/parser": "^5.10.2",
        "async-exit-hook": "^2.0.1",
        "aws-sdk": "^2.1069.0",
        "axios": "^0.25.0",
        "babel-plugin-module-resolver": "^4.1.0",
        "body-parser": "^1.19.1",
        "cors": "^2.8.5",
        "cross-env": "^7.0.3",
        "crypto-js": "^4.1.1",
        "eslint-import-resolver-node": "^0.3.2",
        "eslint-plugin-import": "^2.14.0",
        "eslint-plugin-jsx-a11y": "6.x",
        "eslint-plugin-react": "7.x",
        "express": "^4.17.2",
        "express-jwt": "^6.1.0",
        "express-jwt-authz": "^2.4.1",
        "express-query-boolean": "^2.0.0",
        "express-validator": "^6.14.0",
        "jwks-rsa": "^2.0.5",
        "morgan": "^1.10.0",
        "morgan-json": "^1.1.0",
        "node-fetch": "^3.2.0",
        "pg": "^8.7.3",
        "prettier": "^2.5.1",
        "redis": "^4.0.3",
        "sinon": "^13.0.1",
        "slugify": "^1.6.5",
        "tsconfig-paths": "^3.12.0",
        "tspath": "^1.3.7",
        "typeorm": "^0.2.41",
        "winston": "^3.5.1",
        "winston-daily-rotate-file": "^4.6.0"
      }
    }

我试过的

  • 通过将"outDir“更改为”./build2 2“来确保使用tsconfig.json文件。当尝试构建时,创建了一个build2文件夹,因此使用了tsconfig.json文件。
  • 将"skipLibCheck“设置为false (No effect)
  • Deleting all node_modules和rerunning yarn install )(在api/tsconfig.json 中没有effect)
  • Adding "types": []到"compilerOptions”)(Babel和sinon错误已经消失,但我仍然得到了以下150行ones)

代码语言:javascript
复制
../node_modules/@types/express-serve-static-core/index.d.ts(99,68): error TS1110: Type expected.
../node_modules/@types/node/assert.d.ts(12,72): error TS1144: '{' or ';' expected.
../node_modules/@types/node/index.d.ts(72,1): error TS1084: Invalid 'reference' directive syntax.
../node_modules/express-validator/src/chain/validators-impl.d.ts(79,27): error TS1005: ',' expected.

版本打印

nvm v 1.1.8.

nvm current v16.13.2

yarn -v 1.22.18

yarn run tsc --version版本2.9.2

谢谢你的帮助!

EN

Stack Overflow用户

回答已采纳

发布于 2022-03-21 17:59:56

我找到了罪魁祸首。它是"tspath“依赖。

为了删除它,我做了“纱线工作区api删除tspath”。

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71541190

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档