0

I am using Yarn v3 and PnP.

Following the Editor Setup#vscode guide, but the VSCode will use the TypeScript version generated by below command:

yarn dlx @yarnpkg/sdks vscode

It will generate a new directory called .yarn/sdks, and there will be a generated TypeScript package there. The package information:

{
  "name": "typescript",
  "version": "4.9.5-sdk",
  "main": "./lib/typescript.js",
  "type": "commonjs"
}

There is a .vscode/settings.json:

{
  "typescript.tsdk": ".yarn/sdks/typescript/lib",
  "search.exclude": {
    "**/.yarn": true,
    "**/.pnp.*": true
  },
  "prettier.prettierPath": ".yarn/sdks/prettier/index.js",
  "typescript.enablePromptUseWorkspaceTsdk": true
}

As you can see, I can select the generated typescript.

But before I migrate to Yarn v3 and PnP, I use npm as my package manager. I can select the TypeScript version which is the project's devDependency.

package.json:

"typescript": "^4.1.2"

This makes the VSCode typescript version and the project's typescript inconsistent.

My project use "typescript": "^4.1.2", but VSCode use 4.9.5-sdk.

How can I select the typescript used in my project rather than the typescript generated by yarn dlx @yarnpkg/sdks vscode command?

Since I use PnP, there is no more node_modules directory. VSCode can't select the TypeScript version from node_modules anymore.

Lin Du
  • 88,126
  • 95
  • 281
  • 483

0 Answers0