我在typescript的.tsconfig
中设置了路径别名,所以我的导入看起来更干净.
在我的代码中,当我try 像这样导入我的接口时
import { ApiResponse } from '@api';
埃斯林特抱怨:Unable to resolve path to module '@api'
相关文件
在my tsconfig.json中,我设置了如下路径别名:
{
"compilerOptions": {
"moduleResolution": "node",
"baseUrl": "./src",
"paths": {
"@api": ["./types/api"]
},
}
}
我的./src/types/api.ts是这样的:
// 3rd party API response object
export interface ApiResponse {
....
}
最后,我的.eslintrc.json分是这样的:
{
"env": {
"node": true
},
"globals": {
"console": true
},
"plugins": ["@typescript-eslint", "prettier"],
"parser": "@typescript-eslint/parser",
"settings": {
"import/extensions": [".js", ".ts"],
"import/parsers": {
"@typescript-eslint/parser": [".ts"]
},
"import/resolver": {
"node": {
"extensions": [".js", ".ts"]
}
}
}
}
知道我做错了什么吗?