JetBrains 汽车与相关进口产品对比

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

我之前从 VSCode 切换到 WebStorm,我很喜欢它。我只希望自动导入的工作方式与它们在 VSCode 中一直为我工作的方式相同:兄弟和子导入的相对导入,否则绝对导入。假设我在打字稿应用程序中有这个目录树(在我的确切情况下是 React)。

app/
  components/
  pages/

如果我在

app/pages/profile
并且我导入了一个按钮组件,它应该从
app/components/Button
导入。但是如果我在
app/components/Button
需要导入
app/components/Icon
,它应该从
./Icon
导入。在 VSCode 中这很管用,但我一辈子都弄不明白如何在 WebStorm 中做到这一点。根据我的配置,它会在绝对 100% 的时间或相对 100% 的时间内完成。有没有其他人遇到过这个问题并且知道如何解决?我已经尝试了所有“使用来自 tscong.json 的路径映射”选项。

还有我的

tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "jsx": "react-jsx",
    "lib": [
      "esnext",
      "dom"
    ],
    "module": "esnext",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "noUnusedLocals": true,
    "outDir": "./dist/",
    "preserveConstEnums": true,
    "removeComments": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "strictNullChecks": true,
    "sourceMap": true,
    "target": "es5",
    "baseUrl": "./",
    "paths": {
      "app/*": [
        "src/app/*"
      ]
    }
  },
  "exclude": [
    "./.eslintrc.js",
    "dist",
    ".jest",
    "./src/**/*.stories.*"
  ],
  "include": [
    "./scripts/generateServiceWorker.js",
    "./src/**/**/*",
    "./webpack.*.js"
  ]
}
typescript webstorm jetbrains-ide
© www.soinside.com 2019 - 2024. All rights reserved.