Type declaration for js files

I have a boiled down hobby project that I would like to avoid having to add a compile step to (it's all server-side node.js). My thought was to use a tsconfig.json to allow my IDE to report the type errors for me and to establish the types themselves in separate .d.ts files. My tsconfig.json looks like this : { "compilerOptions": { "noEmit": true, "allowJs": true, "checkJs": true, "lib": ["es2022"], "module": "es2022", "target": "es2022", "types": ["node"], "moduleResolution": "node", }, "include": [ "./**/.js", "./*/.d.ts", ], "exclude": [ "node_modules" ] } And just to stay with a simple example I have (These two are in the same directory) Zone.js class Zone { constructor (name) {} } Zone.d.ts declare class Zone { constructor (name :string) } I'm using VSCode, and the report I'm getting from hovering over the name argument in the Zone constructor is any, when I'd expect it to be string. Maybe the answer is obvious and I'm just up too late to see it with my tired brain, but any feedback here is appreciated. Thank you
1 Reply
jakey___
jakey___12mo ago
I'm further noticing that if I import the Zone class here into another file and start using the class, it'll have the typescript checking i was hoping for. It just doesn't seem to work in the original class file yeah, i've basically concluded it's not possible. google and chatgpt keep giving me the same answer in circles. guess I'll just stick to jsdoc typing.