microsoft / microsoft/TypeScript-TmLanguage

TypeScript Syntax highlighting is wrong when comments are inside type definition

Đang mở
#989 1 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

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

Mô tả

Type: Bug

Syntax highlighting in TypeScript is wrong in cases where there are comments in the type.

type MyType =
  | null //
  | undefined;

let test:
  | null //
  | undefined;

let test2:
  | "a" //
  | null;

let a: null | "a"; //

let b: //
  null | "a";

let c: "a" | null;

let d:
  | "a" //
  | null;

let e:
  | "a" //
  | null
  | undefined;

let f:
  | "a"
  | null //
  | undefined;

let g:
  | "a"
  | null
  //
  | undefined;

type A = {
  a: null | undefined;
  b:
  | null //
  | undefined;
  c: //
  null | undefined;
  d:
  | "a" //
  | undefined
  | null //
  | true;
};

Below is a screenshot of the same code in VSCode and in the TypeScript playground. The typescript playground textmate grammar seems to handle all these cases correctly, but the VSCode one doesn't. Please note that there are some differences in the theme (property names are blue, keywords in type definitions are green), but the VSCode grammar is inconsistent with itself.

image

Keywords: Textmate Grammar

VS Code version: Code - Insiders 1.82.0-insider (d62534a60f7eb4280bcbee66bbd84a2e15f13765, 2023-08-10T05:33:20.243Z)
OS version: Windows_NT x64 10.0.22000
Modes:
Remote OS version: Linux x64 5.15.90.1-microsoft-standard-WSL2
Remote OS version: Linux x64 5.15.90.1-microsoft-standard-WSL2

System Info
Item Value
CPUs AMD Ryzen 9 5900X 12-Core Processor (24 x 4200)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.92GB (5.45GB free)
Process Argv --crash-reporter-id 68f6fdac-c31a-432d-8c54-337698814abd
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 5.15.90.1-microsoft-standard-WSL2
CPUs AMD Ryzen 9 5900X 12-Core Processor (24 x 4200)
Memory (System) 15.58GB (5.49GB free)
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 5.15.90.1-microsoft-standard-WSL2
CPUs AMD Ryzen 9 5900X 12-Core Processor (24 x 4200)
Memory (System) 15.58GB (5.49GB free)
VM 0%
Extensions: none
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vslsvsres303:30308271
pythontb:30258533
vsc_aacf:30263846
pythonptprofiler:30281269
vshan820:30294714
vscod805:30301674
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30404738
py29gd2263:30784851
vsclangdf:30492506
c4g48928:30535728
dsvsc012:30540252
pynewext54:30618038
2i9eh265:30646982
showlangstatbar:30737417
24365598:30687740
pythonfmttext:30716741
fixshowwlkth:30771523
showindicator:30805243
pythongtdpath:30726887
i26e3531:30792625
gsofa:30797620
welcomedialog:30812478
pythonnosmt12:30779711
pythonidxpt:30768918
pythonnoceb:30776497
copilotsettingt:30808721
dsvsc013:30777762
dsvsc014:30777825
diffeditorv2:30786206
pythonmhint1:30815193

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.

Hướng nghiên cứu

Bắt đầu bằng cách xác định các quy tắc ngữ pháp TextMate của TypeScript trong repository này và tái hiện vấn đề bằng các ví dụ TypeScript trong báo cáo. So sánh cách tô sáng các chú thích bên trong các định nghĩa kiểu với VS Code và TypeScript playground. Được coi là hoàn tất khi các trường hợp bị ảnh hưởng được tô sáng nhất quán mà không làm hỏng hành vi hiện có của ngữ pháp.

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

Đánh giá

Công nghệ
typescript
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/100

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.