Visual Studio Code中导入模块时Intellisense无法工作

14

当使用 JavaScript (es2015) 的 import 时,智能感应好像失效了。

在同一个文件中工作时,VSC 会根据 JSDoc 提供正确的方法提示。

enter image description here

但是,当在另一个文件中引入该类时,智能感应好像完全失效了(david.david,wtf?)。

enter image description here

我需要在 Visual Studio Code 中进行任何设置才能使其正常工作吗? 我尝试调整了我的 jsconfig 文件来使用 es2015 imports 和 es6,但没有成功。

我的 jsconfig.json:

{
    "compilerOptions": {
        "module": "es6"
    }
}

我在使用Code时遇到了很多es2015的问题。最终放弃了它,回到了Atom... - erichardson30
我似乎在这里找到了问题 https://github.com/Microsoft/vscode-react-native/issues/61 这是一个已知的 bug。 - koningdavid
1个回答

11

由于您正在使用没有 defaultexport,因此需要启用 allowSyntheticDefaultImports

{
    "compilerOptions": {
        "target": "es6",
        "allowSyntheticDefaultImports": true
    }
}

同样的情况也发生在

import fs from 'fs';
import axios from 'axios';

还有其他人。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接