如何让jsDoc“导入"使用 vscode? [英] How to make jsDoc "import" work with vscode?

查看:44
本文介绍了如何让jsDoc“导入"使用 vscode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用@import 导入一个节点模块,但似乎visual studio 代码没有得到它.还是我做错了?

I want to import a node module with @import, but it seems visual studio code is not getting it. Or am I doing it wrong?

推荐答案

我个人建议 TypeScript 而不是 JSDoc.

Personally I would suggest TypeScript over JSDoc.

尽管如此,尝试这样的事情?(JSDoc 中没有 @import 标签).

Nevertheless, try something like this? (there is no @import tag in JSDoc).

// path/to/UiStore.js

/**
 * @typedef UiStore
 * @type {object}
 * @property {string} foo - description for foo
 * @property {string} bar - description for bar
 */

// path/to/another.js

/** @typedef {import("path/to/UiStore").UiStore} UiStore */

/** @type {UiStore} */
const uiStore = {
  foo: 'hello',
  bar: 'world',
};

使用 mobx-state-tree 是这样工作的:

With mobx-state-tree it works like this:

在文件 UiStore.js 中:

In file UiStore.js:

export const UiStoreType = UiStore.Type

然后在 path/to/another.js

and then in path/to/another.js

/**
 * @typedef Props
 * @prop { import("../stores/UiStore").UiStoreType } uiStore
 * @prop { import("../stores/DbStore").DbStoreType } dbStore
 */

这篇关于如何让jsDoc“导入"使用 vscode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆