Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Typescript baseUrl在React Typescript项目中不工作_Reactjs_Typescript_Eslint Config Airbnb - Fatal编程技术网

Reactjs Typescript baseUrl在React Typescript项目中不工作

Reactjs Typescript baseUrl在React Typescript项目中不工作,reactjs,typescript,eslint-config-airbnb,Reactjs,Typescript,Eslint Config Airbnb,我在我的tsconfig.json文件中定义了baseUrl: "baseUrl": "src", 在.eslintrc.js中,我有: parser: '@typescript-eslint/parser', parserOptions: { ecmaFeatures: { jsx: true, }, ecmaVersion: 2018, sourceType: 'module', project

我在我的
tsconfig.json
文件中定义了
baseUrl

"baseUrl": "src",
.eslintrc.js
中,我有:

parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2018,
    sourceType: 'module',
    project: './tsconfig.json',
  },
现在,在例如
index.tsx
中,我可以从“组件/布局”导入组件,如
导入布局

当我运行
gatsby develope
时,会出现如下错误:

If you're trying to use a package make sure that 'components/layout' is installed. If you're trying to use a local file make sure that the path is correct.
error undefined failed

这里缺少什么,为什么找不到我的组件?

您必须在
.eslintrc.js
中添加
导入/解析程序设置,以便Webpack可以识别组件的
导入
(我假设它们具有
.tsx
扩展名)

设置:{
“导入/解析程序”:{
节点:{
路径:[
“src”
],
扩展:[
“.ts”,
“.tsx”
]
}
}
},

您必须在
.eslintrc.js
中添加
import/resolver
设置,以便Web包可以识别组件的
导入
(我假设它们具有
.tsx
扩展名)

设置:{
“导入/解析程序”:{
节点:{
路径:[
“src”
],
扩展:[
“.ts”,
“.tsx”
]
}
}
},

谢谢,我仍然收到错误信息。我是否还必须添加nom包
eslint导入解析器typescript
?事实上,由于您使用的是Gatsby,因此可以使用类似的插件。我认为在我查看其他插件之前,配置会更容易,我是否必须安装
eslint导入解析程序typescript
才能在
.eslintrc.js
中使用上述设置
import/resolver
?不,插件应该做一些小动作,我仍然得到错误。我是否还必须添加nom包
eslint导入解析器typescript
?事实上,由于您使用的是Gatsby,因此可以使用类似的插件。我认为在我查看其他插件之前,配置会更容易,我是否必须安装
eslint导入解析程序typescript
才能在
.eslintrc.js
中使用上述设置
import/resolver
?不,插件应该做到这一点