【发布时间】:2021-12-29 03:31:58
【问题描述】:
我正在使用 Yarn Workspaces 开发 Yarn 2 monorepo,在此过程中,我在尝试让 VSCode 解析 TypeScript 类型时遇到了困难。
我已经按照provided by Yarn 的信息了解如何让 VSCode 解析这些类型。
然而,VSCode不正确解析类型除非,在我的tsconfig.json中,我注释掉以下两行:
"include": ["src/**/*"],
"exclude": ["tests/**/*"],
这不是一个 巨大 问题,因为它可以工作,但是现在当我构建我的打字稿项目时,我在构建中包含了 tests 文件夹,这并不理想。
这些设置和 Yarn 的交互方式有什么我遗漏的吗?是否有已知的解决方法可以让 typescript 正确构建并让 VSCode 正确解析类型?
我的完整tsconfig.json如下:
{
// "include": ["src/**/*"],
// "exclude": ["tests/**/*"],
"compilerOptions": {
/* Language and Environment */
"target": "es2016",
/* Modules */
"module": "es6",
"moduleResolution": "node",
/* Emit */
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "dist",
/* Interop Constraints */
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
/* Type Checking */
"strict": true,
"skipLibCheck": true,
}
}
【问题讨论】:
标签: typescript visual-studio-code jestjs yarnpkg yarn-workspaces