Reputation: 191
I'm making a node library where it's important for me to have the types for consumers but for some reason when I import my class from outside src VS Code will replace types on hints of some of the functions to any or any[], it seems that it will only do that for complex types but why does it happen only outside src and why at all?
When I ctrl + hover, it does show the correct type on the hint, but still when filling in the parameters VS Code doesn't help at all with object variable names or union types
I tried exporting all the types used in the function from the main entry point (src/index.ts) but that doesn't seem to help.
Is that a vscode bug? Something I can do to fix it?
https://github.com/origeva/node-sponsorblock-api
Upvotes: 6
Views: 1435
Reputation: 191
Enable the declaration files option in your tsconfig to generate .d.ts files that describe your types.
{
"compilerOptions": {
"declaration": true
}
}
Visit the documentation for more info.
Upvotes: 1