Reputation: 19014
I'm trying to setup TypeScript on a JS codebase with allowJs
and checkJs
I have a JSDoc that uses an interface as a parameter type:
* @param {IPlugin[]|IPlugin} plugins plugin instance(s).
In the same file, I have the interface defined via JSDoc:
/**
* Plugin extension hooks.
* @interface IPlugin
* @since 2.1.0
*/
This looks like valid JSDoc to me. However, TypeScript is failing on it:
src/core/core.plugins.js:243:13 - error TS2304: Cannot find name 'IPlugin'.
243 * @param {IPlugin[]|IPlugin} plugins plugin instance(s).
Any ideas how I get this to work?
Upvotes: 4
Views: 3384
Reputation: 19014
@interface
is not supported by Typescript: https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc
It is suggested to use d.ts
files instead: https://github.com/microsoft/TypeScript/issues/33207#issuecomment-527680208
Might also be able to hack it by using @typedef
: https://github.com/AlCalzone/ioBroker.js-controller/blob/9fbbb890290b07af5d9dfb7ae90bf92f2d0be178/lib/tools.js#L1329
Upvotes: 4