yo code TypeScript template missing "types": ["mocha"] after TypeScript 6.0 change
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- typescript
- Lĩnh vực
- testing-qa, tooling
Hướng nghiên cứu
Bắt đầu bằng cách xác định các template TypeScript tạo ra tsconfig.json và src/test/extension.test.ts được scaffold, sau đó chạy yo code để tái hiện suite kiểm thử bị thiếu và các lỗi kiểm thử. Cập nhật cấu hình đã tạo liên quan với các type Mocha bắt buộc và xác minh rằng một extension TypeScript mới được tạo có thể biên dịch mà không có các lỗi này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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).
- Ngôn ngữ chính
- JavaScript
- Star
- 1.6k
- Fork
- 262
- Merge trung bình
- 3 giờ 44 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/vscode-generator-code
-
Generator specifies string for `lineComment` in new languagesCó thể đã có người làm @DanielRosenwasser đã nhận 68 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/vscode-generator-code#597 · 1 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
microsoft/vscode-generator-code#575 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 56/100
-
DeprecationWarningsĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Tất cả issue của microsoft/vscode-generator-code
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
nodejs/node#66743 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OWASP/cve-lite-cli#1335 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Channels status: needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
mastra-ai/mastra#27093 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
category/development priority/P1 scope/ci-cd scope/testing status/ready-for-agent type/bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
QwenLM/qwen-code#14225 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100