【问题标题】:How have IDE type awareness with app-module-path in Visual Studio Code如何在 Visual Studio Code 中使用 app-module-path 来识别 IDE 类型
【发布时间】:2017-11-02 18:33:44
【问题描述】:

我在他们使用 app-module-path 的节点环境中,以便始终可以从基本路径写入需求。

因此,所有路径都可以是:const something = require('/api/something'),而不必使用类似以下内容的文件夹结构:const something = require('../../api/something)

没有确切的路径,VSCode 说所有类型都是任何类型。这意味着“转到定义”之类的功能将不起作用。

有没有办法配置 VSCode 来解决这个问题?

【问题讨论】:

    标签: node.js visual-studio-code


    【解决方案1】:

    经过一番搜索,我发现这可以通过使用具有以下设置的 jsconfig.son 文件来完成。

    {
        "compilerOptions": {
            "target": "ES6",
            "allowSyntheticDefaultImports": true,
            "jsx": "react",
            "module": "commonjs",
            "baseUrl": ".",
            "paths": {
                "*": [
              "*",
              "app/*"
            ]
            }
        },
        "include": [
          "app/**/*.js"
        ]
    }
    

    【讨论】:

    • 我有完全相同的问题,但使用的是 Webstorm。我正在尝试找到类似的配置,但到目前为止还没有成功。
    猜你喜欢
    • 2018-09-10
    • 1970-01-01
    • 1970-01-01
    • 2020-10-07
    • 2018-10-19
    • 2020-04-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-17
    相关资源
    最近更新 更多