[英]VS Code and Yarn PnP
紗線 pnp sdk 和 typescript 有什么不兼容的地方嗎? 我已經通過yarn sdks
安裝了 sdk,並且在 TS 服務器日志中它似乎是從緩存中提取的(例如:)
/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
感謝任何見解或指示以進一步調查。
SDK 目前與 TS 4.5 不兼容:
https://github.com/yarnpkg/berry/issues/3722
降級到 4.4.4 修復它:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.