【发布时间】:2022-07-25 03:06:08
【问题描述】:
在我的 tsconfig.json 中,我排除了文件夹
"src/__test__"
来自编译。现在的问题是 VS Code 找不到模块。我用 Jest 运行测试没有问题,模块已解决,但此消息很烦人。我也不能使用自动完成。 有没有办法为测试和源代码创建单独的打字稿配置文件?到目前为止,我使用 "extend": "../../tsconfig.json" 创建了 tsconfig.test.json 文件,但它没有按我的预期工作。编译器只读基 tsconfig.json。
找不到模块 <..> 或其对应类型 声明.ts(2307)
tsconfig.json
{
"compilerOptions": {
"module": "esnext",
"esModuleInterop": true,
"target": "es5",
"lib": ["es6", "dom"],
"sourceMap": false,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"baseUrl": ".",
"outDir": "dist",
"resolveJsonModule": true,
"paths": {
"components/*": ["src/components/*"],
"utils/*": ["src/utils/*"],
"api/*": ["src/api/*"],
"src/*": ["src/*"]
}
},
"exclude": ["src/__tests__"]
}
【问题讨论】:
标签: typescript visual-studio-code tsconfig