【发布时间】:2020-11-08 23:36:45
【问题描述】:
我正在尝试将 VSCode IntelliSense 用于函数参数。
它适用于以下代码。但不幸的是,只有在输入 .default. 之后
但我想在parentObject 上使用 IntelliSense。
export default class Data {
/** @param {import('./mainStore')} parentObject */
constructor(parentObject) {
parentObject.default.XXX //<--I get correct Intellisense for the XXX after the "default"
}
}
使用import('./mainStore').default 不起作用。
export default class Data {
/** @param {import('./mainStore').default} parentObject */
constructor(parentObject) {
parentObject.XXX //<--No IntelliSense here"
}
}
编辑:这是mainStore.js 的缩短版本。导入的类包含一些函数。我认为这不是很好的风格,但我想构建我的函数和数据。
import UserStore from "./userStore";
import DataStore from "./dataStore";
const MainStore = {
user: new UserStore(),
data: new DataStore()
construct() {
this.data = new DataStore(this);
this.user = new UserStore(this);
return this;
}
}
export default MainStore;
我添加了两张图片,希望能解释我的意思:
Image - Working IntelliSense, but only after using ".default"
Image - Not working IntelliSense with import('./mainStore').default
我已经尝试过命名导出,但它也不起作用。
如何让 IntelliSense 为 parentObject 工作?
非常感谢!
【问题讨论】:
-
您介意详细说明您在做什么吗?您是将对象传递给构造函数还是传递
import('./mainStore')? -
抱歉,我刚刚添加了
mainStore.js的缩短版
标签: javascript visual-studio-code intellisense jsdoc