小编Tim*_*rov的帖子

eslint + typescript + tsconfig 中的路径:ESLint:无法解析模块“@components/some-module”的路径。(导入/无未解析)

我为路径(别名)添加打字稿配置:

配置文件

{
  "compilerOptions": {
    "jsx": "react",
    "baseUrl": "src",
    "paths": {
      "@components/*": ["components/*"]
    }
  },
  "exclude": [
    "node_modules",
    "public"
  ]
}

Run Code Online (Sandbox Code Playgroud)

之后,我尝试导入这样的东西:

import Header from '@components/header';
Run Code Online (Sandbox Code Playgroud)

现在我在 eslint 中遇到错误: ESLint: Unable to resolve path to module '@components/header'.(import/no-unresolved)

typescript reactjs eslint typescript-eslint

9
推荐指数
1
解决办法
9991
查看次数

标签 统计

eslint ×1

reactjs ×1

typescript ×1

typescript-eslint ×1