如何使用@implements

时间:2018-08-29 08:37:53

标签: node.js jsdoc

我有一个Model类(在nodejs中),我想从AuthorizationCodeModel实现它。

我希望WebStorm检测到我的模型实现了该接口并建议我自动完成

Interface

型号:

  /**
   * @implements AuthorizationCodeModel
   */
  class Model {
  }

@implements AuthorizationCodeModel不起作用。如何使用JSDoc?

1 个答案:

答案 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

https://intellij-support.jetbrains.com/hc/en-us/community/posts/206352279-How-to-not-reference-other-js-files

intellisense and code complete for DefinitelyTyped (TypeScript type definitions) on WebStorm IDE