typescript - VSCode 在我的项目中找不到 TypeScript 模块和类型
问题描述
我有一个使用 TypeScript 的项目。它从命令行运行良好,但是当我在 VSCode 中打开它时,它抱怨无法找到各种模块和类型:
文件结构为:
- app/
- javascript/
- src/
- app_reducer.ts
- spec/
- javascript/
- _test_helpers
- factories.ts
- tsconfig.json
- tsconfig-test.json
此投诉来自一个文件factories.ts
。tsconfig.json
并且tsconfig-test.json
是:
{
"//": {
"strictPropertyInitialization": true,
"strict": true
},
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"declaration": false,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"lib": ["es2017", "dom"],
"module": "es6",
"moduleResolution": "node",
"alwaysStrict": true,
"noImplicitAny": true,
"noImplicitThis": true,
"paths": {
"src/*": ["app/javascript/src/*"]
},
"sourceMap": true,
"strictNullChecks": true,
"target": "es5",
"jsx": "react"
},
"exclude": [
"spec",
"node_modules",
"vendor",
"public"
],
"compileOnSave": false
}
{
"compilerOptions": {
"paths": {
"src/*": ["app/javascript/src/*"],
"_test_helpers/*": ["spec/javascript/_test_helpers/*"]
}
},
"extends": "./tsconfig",
"exclude": [
"node_modules",
"vendor",
"public"
]
}
从命令行运行时它可以正常工作:
yarn tsc --noEmit -p tsconfig-test.json
解决方案
推荐阅读
- gremlin - Tinkerpop gremlin 忽略顶点
- javascript - 无法理解异步函数中的多个等待
- process - 旧 linux 内核中的子运行优先语义
- reactjs - 是否可以使用 AppSync VTL 使用 BatchPutItem (BatchWriteItem) 在 DynamoDB 上插入超过 25 个项目?
- mysql - 我们可以使用 OR 关键字进行 sql 连接吗?
- mapbox - 如何在一个缩放级别后显示较小的道路?
- c# - 使用 Winapp 驱动程序拖放 UI 元素
- regex - 删除所有流文件属性,明确定义的除外
- php - 从服务器检索 PHP 记录?
- python - 搜索带有 ts 扩展名的文件失败