Using VSCode is almost possible to have the benefits from Typescript in plain .js thanks to jsDoc notation and a tsconfig.json file:
{
"compileOnSave": false,
"compilerOptions": {
"noEmit": true,
"allowJs": true,
"checkJs": true,
"target": "es6",
"resolveJsonModule": true,
"moduleResolution": "node",
},
"include": ["index.js", "./src"]
}
/**
* @return {Promise<string>}
*/
const foo = Promise.resolve('hi');
module.exports = foo;
Now, is it possible to reference an interface defined in a d.ts at node_modules? in particular I'm returning a -let's call- "my_dependency.Storage" object but I'm unable to reference it using plain javascript:
/**
* @param {Storage} storage
*/
const goo = storage => ...
will understand that I'm refering to Web Storage API from lib.dom.d.ts
- The equivalent typescript would be:
import {Storage} from "my_dependency"
- I've tried using triple slash directives unsuccessfully
///<reference path="node_modules/my_dependency/lib/index.d.ts" />
- I'm expecting something like (pseudo-code)
/**
* @param {my_module.Storage} storage
*/