typescript - VS Code och Yarn PnP
Finns det några inkompatibiliteter mellan yarn pnp sdk och TypeScript? Jag har installerat sdk:n via yarn sdks och i TS Server-loggarna verkar det hämta från cache (t.ex:)
/osi/disp/vob/web/.yarn/cache/typescript-patch-04b86b0e5c-24a439e062.zip/node_modules/typescript/lib/lib.es5.d.ts
Ändå kan VS Code inte hitta moduler:
Cannot find module 'react' or its corresponding type declarations.
Det byggs och körs via webpack. Detta verkar vara ett VS Code/sdk-artifakt.
Försöker spåra react-lösning, det finns några konstiga anteckningar:
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
De där mapparna finns inte, och det verkar som att det kan tolka 'react' som './react'
tsconfig :
{
"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
}
}
Enkel reproduktion: https://github.com/rcketscientist/vs-code-pnp-test
Jag uppskattar alla insikter eller tips för att undersöka vidare.
Svar #1
SDK:n är för närvarande inkompatibel med TS 4.5:
https://github.com/yarnpkg/berry/issues/3722
Nedgradering till 4.4.4 åtgärdar det:
- yarn ta bort typescript
- rm -rf .yarn/sdks/typescript
- yarn add -D [email
- garn dlx @yarnpkg/sdks bas