Code Highlighting Broken for Generic Functions with Default Values in .tsx Files

Đang mở
#1,042 4 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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript
Lĩnh vực
tooling

Hướng nghiên cứu

Tái hiện ví dụ trong một tệp .tsx và so sánh phần tô sáng của nó với cùng đoạn mã trong một tệp .ts. Kiểm tra các quy tắc ngữ pháp TextMate của TypeScript cho các tham số generic có giá trị mặc định và các hàm mũi tên; được xem là hoàn tất khi màu của .tsx khớp với phần tô sáng TypeScript dự kiến mà không ảnh hưởng đến hành vi .ts hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Does this issue occur when all extensions are disabled?: Yes

  • Version: 1.95.0-insider
  • Commit: 804f450ca900d24db25e7174e8b6dfb3fb2a318c
  • Date: 2024-10-22T13:30:10.100Z
  • Electron: 32.2.1
  • ElectronBuildId: 10427718
  • Chromium: 128.0.6613.186
  • Node.js: 20.18.0
  • V8: 12.8.374.38-electron.0
  • OS: Darwin x64 24.0.0

Describe the bug
In VSCode, when writing a generic function with default values in a .tsx file, code highlighting is broken and colors are displayed incorrectly. The same code works fine in a .ts file.

To Reproduce

  1. Open VSCode and create a new .tsx file.
  2. Write the following code:
const func = <T = string,>(args: T): string => {
  const t = typeof args;
  if (typeof t === 'string') {
    return t.split(',').join('_');
  }
  return '';
};
func('');

const add = (a: number, b: number) => {
  return a + b;
};
  1. Observe the code highlighting.

Expected behavior
Code highlighting should work correctly and match the behavior in .ts files.

Screenshots
In .tsx file:
Image
Pay attention to the screenshot where the generic default parameter definitions, colons, and arrow function arrows are all highlighted in red, while the colors of keywords such as const, if, and return are incorrect.

In .ts file:
Image

Ngôn ngữ chính
TypeScript
Star
471
Fork
149
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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/TypeScript-TmLanguage

Tất cả issue của microsoft/TypeScript-TmLanguage

Issue tương tự

Thêm issue về TypeScript

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.