VS Code jsconfig auto指向index.js

问题描述 投票:0回答:1

我想使用Visual Studio代码在React Native中使用绝对路径。按照本教程:tuturial,我可以使它工作。

例如,在我的SRC文件夹中,我创建了package.json

{
  "name": "@src"
}

但是当我尝试使用import A from '@src/...'时,intellisense不起作用,通过在根中创建jsconfig.json来修复它:

{
  "compilerOptions": {
    "module": "es6",
    "paths": {
      "@src/*": ["src/*"],
      "@locale/*": ["locale/*"]
    },
    "baseUrl": "./"
  }
}

它适用于from部分,但不适用于import部分,我要放/index以使VS显示暗示,如果/index不在那里,暗示没有显示。有没有什么方法可以让它工作,而不是在每次进口中加入/index

import { notShowHintHere } A from '@src/componentA'

import { showHintHere } A from '@src/componentA/index'
react-native visual-studio-code vscode-settings
1个回答
0
投票

最后,我在这里找到了https://github.com/Microsoft/vscode/issues/24715的答案,更新了compilerOptions.module的作品

"compilerOptions": {
    "module": "commonjs"
  }
© www.soinside.com 2019 - 2024. All rights reserved.