VS代码:“转到定义”不适用于导出的类

时间:2018-07-14 23:15:11

标签: javascript annotations visual-studio-code definition

exported类上,单击属性类型注释,我无法在VS Code中使用“转到定义”功能。这是示例:

//Core.js
export default class Core { constructor() {} }

//Engine.js
export default class Engine{
    /** @type {Core} core */
    constructor(core) {
        /** @type {Core} */            
        this.core = core;
    }
} 

//index.js
import Core from './Core';
import Engine from './Engine';

const core = new Core();
const engine = new Engine(core);

当我在Engine.js中并想通过单击注释{Core}进入Core.js类时,它不起作用。如果我使用“转到定义”,则VS代码会说:未找到“ Core”的定义。

我做错了什么? 可能吗 谢谢

2 个答案:

答案 0 :(得分:0)

使用curl批注将类型“导入”到文件中,如下所示:

@typedef

答案 1 :(得分:0)

请向我们显示您的项目文件层次结构。很有可能您不是在从项目的根目录开始定义导入。

import Page from 'components/Page'; //1


import Page from './../components/Page'; //2

1对我不起作用,但2对我有用。