这是显示问题的Github MCVE。npm run compile显示错误。我正在尝试这样做:import {Todo} from '@test';但这还没有解决。src / index.ts:1:20-错误TS2307:找不到模块'@test'。我paths进去了tsconfig.json。 "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ "paths": { "@fs/": ["src/"], "@test/": ["test/"] }, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */有什么想法吗?
2 回答

回首忆惘然
TA贡献1847条经验 获得超11个赞
不要调整VS Code导入模块说明符设置(根据一些浮动的答案)。并且不要删除全局模式。实际上,请在以下内容中添加更多内容:
"baseUrl": "./",
"paths": {
"@fs/*": ["src/*"],
"@test/*": ["test/*"]
},
请注意,glob在键AND值中。有时很难发现这一点。
如果目标是文件,则应在键和值中省略该glob。

烙印99
TA贡献1829条经验 获得超13个赞
删除全局模式:
"paths": {
"@test": "./test"
}
您的解决方案应该可以正常工作,但是文档不使用glob,并且在使用glob时有一些报告的intellisense错误。
添加回答
举报
0/150
提交
取消