Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

yo code TypeScript template missing "types": ["mocha"] after TypeScript 6.0 change

Đang mở Phù hợp với người mới
#599 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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 under node_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
  1. Run yo code and choose a TypeScript extension.
  2. Open the generated project in VS Code.
  3. Observe red errors on suite and test in src/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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/vscode-generator-code

Tất cả issue của microsoft/vscode-generator-code

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.