yo code TypeScript template missing "types": ["mocha"] after TypeScript 6.0 change
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- testing-qa, tooling
Research direction
Start by locating the TypeScript templates that generate tsconfig.json and the scaffolded src/test/extension.test.ts, then run yo code to reproduce the missing suite and test errors. Update the relevant generated configuration with the required Mocha types and verify that a newly generated TypeScript extension compiles without those errors.
Written by the indexing model from the issue text.
Description
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).
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 262
- Avg merge
- 15d 22h
- Merged PRs (30d)
- 1
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/vscode-generator-code
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/vscode-generator-code#597 · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/vscode-generator-code#575 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 56/100
-
DeprecationWarningsOpen
Difficulty 3/5 1-2 days Newbie friendliness 35/100
All issues in microsoft/vscode-generator-code
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
keyxmakerx/Chronicle#967 ·
Maintainers usually reply within 1 day
-
good first issue hacktoberfest
Difficulty 1/5 Under an hour Newbie friendliness 92/100
RogueAlg0/taken#386 · 3 comments ·
Maintainers usually reply within 1 day
-
external-issue to-triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
LearningCircuit/local-deep-research#7067 ·
Maintainers usually reply within 1 day