node.js - 如何使用@implements
问题描述
我有一个Model
类(在 nodejs 中),我想从AuthorizationCodeModel
.
我希望 WebStorm 检测到我的模型实现了接口并建议我自动完成
接口。
模型:
/**
* @implements AuthorizationCodeModel
*/
class Model {
}
不@implements AuthorizationCodeModel
工作。如何使用 JSDoc?
解决方案
打字稿中的示例界面
interface ClockInterface {
currentTime: Date;
}
class Clock implements ClockInterface {
currentTime: Date;
constructor(h: number, m: number) { }
}
https://www.typescriptlang.org/docs/handbook/interfaces.html
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
推荐阅读
- scala - 适用于 RDD 和 Seq 的通用方法
- jquery - jQuery Animate - 恢复到原始大小
- bash - 从 bash 脚本中运行时,flake8 的行为不同
- node.js - setTimeouts 并不总是适用于 node.js discord bot
- sql - 如何在 SQL Server 中将数据从 prod 服务器插入到 dev 服务器
- python - 动态规划,最小硬币数量
- java - Android 权限 ACCESS_FINE_LOCATION 始终被拒绝
- ios - MapBox 用户位置图标 | iOS
- javascript - 获取当前 tbody 下方的 tbody
- java - 将一些 JSON 从 php 解析到 android 时出现问题