How to use @implements

Viewed 1124

I have a Model class (in nodejs) and I want to implement it from AuthorizationCodeModel.

I want WebStorm detect that my model implemented the interface and suggest me auto complete

Interface.

Model:

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

the @implements AuthorizationCodeModel is not working. How can I use JSDoc?

1 Answers

example interface in typescript

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 examples: http://usejsdoc.org/tags-implements.html


If autocomplete in Webstorm not worked, try to set 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 also use for autocomplete in some popular IDEs

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

Related