【问题标题】:Intellisense not working with imports in Visual Studio CodeIntellisense 不适用于 Visual Studio Code 中的导入
【发布时间】:2016-07-21 09:04:36
【问题描述】:

当使用 javascript (es2015) 导入时,Intellisense 似乎被破坏了。

当我在同一个文件中工作时,VSC 会使用正确的 JSDoc 信息自动建议来自对象的方法。

但是,当在另一个文件中导入 Class 时,Intellisense 似乎完全被破坏了(david.david,wtf?)。

我是否需要调整 Visual Studio Code 中的任何设置才能使其正常工作?我尝试将我的 jsconfig 文件调整为 es2015 导入和 es6,但这不起作用。

我的 jsconfig.json:

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

【问题讨论】:

标签: javascript ecmascript-6 intellisense visual-studio-code jsdoc


【解决方案1】:

因为您使用的是export 而没有default,所以您需要启用allowSyntheticDefaultImports

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

同样的情况发生在

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

还有其他人。

【讨论】:

    猜你喜欢
    • 2016-07-14
    • 1970-01-01
    • 2022-01-21
    • 2019-01-25
    • 1970-01-01
    • 2021-05-24
    • 1970-01-01
    • 2017-09-09
    • 1970-01-01
    相关资源
    最近更新 更多