0

yarn pnp sdk 和 typescript 有什么不兼容的地方吗?我已经通过yarn sdksTS 服务器日志安装了 sdk,它似乎是从缓存中提取的(例如:)

/osi/disp/vob/web/.yarn/cache/typescript-patch-04b86b0e5c-24a439e062.zip/node_modules/typescript/lib/lib.es5.d.ts

然而 VS Code 找不到模块:

Cannot find module 'react' or its corresponding type declarations.

它通过 webpack 构建和运行。这似乎是一个 VS Code/sdk 工件。

试图追踪反应分辨率有一些奇怪的注意事项:

Info 1216 [08:36:07.761] DirectoryWatcher:: Added:: WatchInfo: /osi/disp/vob/web/react 1 undefined Project: /osi/disp/vob/web/tsconfig.json WatchType: Failed Lookup Locations
Info 1217 [08:36:07.761] Elapsed:: 0.06486300379037857ms DirectoryWatcher:: Added:: WatchInfo: /osi/disp/vob/web/react 1 undefined Project: /osi/disp/vob/web/tsconfig.json WatchType: Failed Lookup Locations

这些文件夹不存在,似乎它可能被解释'react''./react'

配置:

{
  "compilerOptions": {
    "baseUrl": "./",
     "target": "es5",
    "lib": [
      "es6",
      "dom",
      "es2016",
      "es2017"
    ],
    "allowSyntheticDefaultImports": true,
    "alwaysStrict": true,
    "declaration": true,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "jsx": "react",
    "module": "commonjs",
    "moduleResolution": "node",
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "removeComments": true,
    "resolveJsonModule": true,
    "skipLibCheck": true
  }
}

简单复制: https ://github.com/rcketscientist/vs-code-pnp-test

感谢任何见解或指示以进一步调查。

4

1 回答 1

0

SDK 目前与 TS 4.5 不兼容:

https://github.com/yarnpkg/berry/issues/3722

降级到 4.4.4 修复它:

  1. 纱线去除打字稿
  2. rm -rf .yarn/sdks/typescript
  3. 纱线添加 -D typescript@4.4.4
  4. 纱线 dlx @yarnpkg/sdks 基础
于 2021-11-23T21:25:50.963 回答