我有一个Model
类(在nodejs中),我想从AuthorizationCodeModel
实现它。
我希望WebStorm检测到我的模型实现了该接口并建议我自动完成
型号:
/**
* @implements AuthorizationCodeModel
*/
class Model {
}
@implements AuthorizationCodeModel
不起作用。如何使用JSDoc?
答案 0 :(得分:1)
打字稿中的示例界面
interface ClockInterface {
currentTime: Date;
}
class Clock implements ClockInterface {
currentTime: Date;
constructor(h: number, m: number) { }
}
https://www.typescriptlang.org/docs/handbook/interfaces.html
What's the difference between 'extends' and 'implements' in TypeScript
JSDOC示例:http://usejsdoc.org/tags-implements.html
如果Webstorm中的自动完成功能不起作用,请尝试设置reference path in js file
/// <reference path="components/someClass.js"/>
/// <reference path="components/someInterface.js"/>
/// <reference path="components/AuthorizationCodeModel.js"/>
/**
* @implements AuthorizationCodeModel
*/
class Model { }
Reference paths
在某些流行的IDE中也用于自动完成
https://madskristensen.net/blog/the-story-behind-_referencesjs
https://www.jetbrains.com/help/webstorm/configuring-javascript-libraries.html
intellisense and code complete for DefinitelyTyped (TypeScript type definitions) on WebStorm IDE