yo code TypeScript template missing "types": ["mocha"] after TypeScript 6.0 change
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- typescript
- 领域
- testing-qa, tooling
调研方向
首先定位生成 tsconfig.json 和脚手架化的 src/test/extension.test.ts 的 TypeScript 模板,然后运行 yo code 以重现缺失的测试套件和测试错误。使用所需的 Mocha 类型更新相关的生成配置,并验证新生成的 TypeScript 扩展可以在没有这些错误的情况下编译。
由索引模型根据 Issue 内容生成。
描述
Problem
When creating a new TypeScript extension with yo code, the generated project installs @types/mocha in devDependencies but does not add "mocha" to the "types" field in tsconfig.json.
This causes immediate TypeScript errors in the scaffolded test file:
Cannot find name 'suite'. Do you need to install type definitions for a test runner? Try npm i --save-dev @types/mocha and then add 'mocha' to the types field in your tsconfig.
Cannot find name 'test'. Do you need to install type definitions for a test runner? ...
Related Issue
This is closely related to #575 (“TypeScript cannot find Node globals with default VSCode tsconfig”). Both issues stem from the same TypeScript 6.0 change to the default "types" behavior.
Root Cause
TypeScript 6.0 changed the default behavior of the "types" compiler option:
- Before TS 6: Omitting
"types"automatically included all packages undernode_modules/@types. - TS 6+: The default is now an empty array (
"types": []). Packages must be listed explicitly.
The current yo code template was written for the old behavior and was never updated for this breaking change.
Expected Behavior
The generated tsconfig.json (or the relevant test tsconfig) should include:
"compilerOptions": {
...
"types": ["mocha", "node"]
}
(or at least "mocha").
Steps to Reproduce
- Run
yo codeand choose a TypeScript extension. - Open the generated project in VS Code.
- Observe red errors on
suiteandtestinsrc/test/extension.test.ts.
Suggested Fix
Update the TypeScript templates in generator-code so that the generated tsconfig.json explicitly lists the required types (mocha and usually node).
- 主要语言
- JavaScript
- 星标
- 1.6k
- 派生
- 262
- 平均合并
- 3 小时 44 分钟
- 30 天内合并 PR
- 2
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/vscode-generator-code 的其他 Issue
-
Generator specifies string for `lineComment` in new languages可能已有人在做 @DanielRosenwasser 于 68 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/vscode-generator-code#597 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 65/100
microsoft/vscode-generator-code#575 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 56/100
-
难度 3/5 1-2 天 新手友好度 35/100
查看 microsoft/vscode-generator-code 的全部 Issue
相似的 Issue
-
Four problem loader browser tests fail on Windows可能已有人在做 @Patriciaath999 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 85/100
juice-shop/juice-shop#3686 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
ScottKirvan/GOMAC#56 ·
-
area:install bug needs-triage
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复