pkyriazo
pkyriazo

Reputation: 111

VSCode typescript autosuggestion broken after migration to pnpm

Setup

We have a monorepo and recently we decided to migrate from yarn to pnpm.

Node version: 14.20.0
pnpm version: 7.9.5
Typescript version: 4.4.2

After migrating to pnpm I updated the package manager settings in VSCode as below:

VSCode package manager setting ESLint package manager setting

Problem

(The problem described below occurs in more that 1 apps, but for the sake of simplicity I will focus on one)

In one of the monorepo's apps we use React with TypeScript.

The problem is that VSCode does not seem to read the nested dependencies' types.

Example

One of the app's dependencies (specified in its package.json) is react-router-dom and react-router-dom has react-router as a dependency.

react-router-dom exports the useLocation hook from react-router.

When I use the useLocation hook, VSCode displays its type as

enter image description here

ESLint does not display any error, so it seems that it is able to follow pnpm's symlinks and read useNavigate hook's type.

Why isn't VSCode able to properly read the nested dependency's types?

Edits

VSCode typescript version used enter image description here

Upvotes: 1

Views: 2111

Answers (1)

pkyriazo
pkyriazo

Reputation: 111

Turns out I had some settings in the monorepo's app's tsconfig wrong.

To work properly, I had to update it:

From

enter image description here

To

enter image description here

Upvotes: 1

Related Questions