microsoft / microsoft/TypeScript

tagged/named rest parameter participating in circular reference causes error

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

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

Bug Domain: check: Type Circularity
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

🔎 Search Terms

named tuple element rest recursive circularly references union unions

🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about everything and didn't find anything relevant
⏯ Playground Link

https://www.typescriptlang.org/play/?esModuleInterop=false&target=99&jsx=0&noFallthroughCasesInSwitch=false&ts=6.0.0-dev.20260416&noUnusedLocals=true&noUnusedParameters=true&noUncheckedIndexedAccess=true#code/KYDwDg9gTgLgBDAnmYcDiEIBMAiEDGActqgLwBQcVcAPnAM4xQCWAdgOaXV0DaARMz4AaOADpxGbHiIkeAXTlcqvPgBtBItllAAuOKwCuAWwBGwKCPGjJuAsW3y5AbnLlQkWAmSoAQgENbGW0ARjgKaloGJjZOCJUNMXEYP3Z2YCw9f0D7YGDHcgB6AoiSiIA9CsqKpUj+dWE4LV19YzMLRNEs6Ry8hRc3cGh4JBQ4LrsSACYwmrpGFg5ZuH4Eq3Gg4En8uOW1BKaQPUNTc0sklLSMsYDuqccXItKn5+eqqvIgA

💻 Code
export type GoodDocNode =
    | string
    | ["i", ...GoodDocNode[]]
    | ["li", index: number, ...GoodDocNode[]];

export type BadDocNode1 =
    | string
    | ["i", ...tagged: BadDocNode1[]]
//             ^^^^^^^^
    | ["li", index: number, ...BadDocNode1[]];

export type BadDocNode2 =
    | string
    | ["i", ...BadDocNode2[]]
    | ["li", index: number, ...tagged: BadDocNode2[]];
//                             ^^^^^^^^
🙁 Actual behavior

Error:

Type alias 'BadDocNode1' circularly references itself.
Type alias 'BadDocNode2' circularly references itself.
🙂 Expected behavior

No errors, because the only differences between the two is the name on the rest parameter in the tuple, nothing structurally is different.

Additional information about the issue

No response

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

Mở 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.

Hướng nghiên cứu

Sử dụng TypeScript Playground được liên kết và bản tái hiện với BadDocNode1/BadDocNode2 làm điểm bắt đầu; điều tra việc kiểm tra bí danh kiểu tuần hoàn cho các tham số rest được đặt tên của tuple. Được xem là hoàn tất khi bản tái hiện không tạo ra lỗi tham chiếu tuần hoàn, trong khi ví dụ GoodDocNode tương đương về cấu trúc vẫn hợp lệ.

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
compilers
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
48/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.