在vite 构建工具下,typescript 指向错误, 在项目中引用时 import {A} from 'components'
会提示 找不到模块“components”或其相应的类型声明。
, 如果这样引用 import {A} from 'components/index'
不会报错
typescript 5.6.2
tsconfig.json 文件
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
"src/*": ["src/*"],
"dashboard/*": ["src/dashboard/*"],
"components/*": ["./src/components/*"],
},
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": [
"src"
]
}
修改过baseUrl,但是不行