tsConfig无法解析@components路径别名问题求助
问题:Vite中@components路径别名正常生效,但TypeScript无法解析
我给./src/components配置了@components路径别名,这个别名在Vite里能正常使用,但TypeScript配置文件无法解析它。我试过StackOverflow上的所有解决方案,都没解决问题。
相关信息
tsconfig.json
{ "compilerOptions": { "target": "ES2020", "useDefineForClassFields": true, "module": "ESNext", "lib": ["ES2020", "DOM", "DOM.Iterable"], "baseUrl": "./src", "paths": { "@components/*": ["components/*"] }, "skipLibCheck": true, /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "preserve", /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true }, "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"], "references": [{ "path": "./tsconfig.node.json" }] }
项目目录结构

报错信息
中文翻译:无法找到模块“@components/Button”或其相应的类型声明。
内容的提问来源于stack exchange,提问作者Achraf FAWZI
相关产品推荐
相关产品推荐


