I am working in a pnpm workspace setup. The folder structure looks like the following
PNPM-WORKSPACE
lib/package.json
lib/generated/a.js
app/tsconfig.json
app/src/b.js
The package.json in the library I am importing modifies the export path of the folder to remove the generated folder name where the generated code is present.
"exports": {
"./*": "./generated/*.js"
},
So import of a.js
which should have been lib/generated/a
becomes lib/a
.
To make Typescript and VS code understand, I have added a path in the tsconfig.json
under app
.
paths: {
"lib/*": ["node_modules/lib/generated/*]
}
This works, but the autocomplete in VS code doesn't work. It still recommends lib/generated/a
. This path is wrong now. Any ideas how to support it? I have looked at a lot of articles, didn't find a solution. Thanks in advance.
I finally found an answer to this problem. The way is to use the typesVersions
in the package.json. So, we would need a new entry in our lib package.json file.
"typesVersions": {
"*": {
"*": ["./generated/*"]
}
},
This solved it for me.