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
?不,插件应该做到这一点