VS Code recognizes custom.d.ts only when it's open

Viewed 294

I have some custom Typescript declarations in a custom.d.ts file, and VS code will read my TS correctly when that file is open, however if the file is closed, VSCode does not "know" about those TS definitions, and I get red underlines all over my code.

One catch is that my tsconfig.json file is NOT in the root directory, and neither is my custom.d.ts file. Why? Because config files in a root directory is so stupid, and I hate it. Why can't config files like that go in a config directory???

Anyway, how can I instruct VSCode to KNOW about my custom.d.ts file? Again, if the file is open, VSCode knows about those definitions, but when I close the file, VSCode forgets about those definitions and the rest of typescript gets red error underlines...

Directory Structure:

/
| - package.json
| - .gitignore
| - client/
    | - client source code.... 
| - server/
    | - @types/
        | - custom.d.ts 
    | - configs/ 
        | - tsconfig.json
        | - .develop.env
1 Answers

Assuming the client is importing stuff from /server, and that server has its own package.json file, you probably want to add { "types": "./@types/custom.d.ts" } to the /server dist's package.json

Related