gpt4 book ai didi

node.js - 如何使用@implements

转载 作者:太空宇宙 更新时间:2023-11-03 22:07:16 26 4
gpt4 key购买 nike

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

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

Interface .

型号:

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

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

最佳答案

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

<小时/>

如果Webstorm中的自动完成功能不起作用,请尝试在js文件中设置引用路径

/// <reference path="components/someClass.js"/>
/// <reference path="components/someInterface.js"/>
/// <reference path="components/AuthorizationCodeModel.js"/>

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

引用路径也用于一些流行的 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

关于node.js - 如何使用@implements,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52073055/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com