microsoft / microsoft/TypeScript

`get self(): this` in an interface crashes the checker (6.0 regression)

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

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

Fixed
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

getConditionalFlowTypeOfType, getAnnotatedAccessorType, Cannot read properties of undefined (reading 'flags'), accessor this type

🕗 Version & Regression Information
  • Crashes in 6.0.3 and nightly (6.0.0-dev.20260416); 5.9.3 is clean — a 6.0 regression
💻 Code
interface I {
    get self(): this
}
🙁 Actual behavior

tsc crashes:

TypeError: Cannot read properties of undefined (reading 'flags')
    at getConditionalFlowTypeOfType (typescript/lib/_tsc.js:65892:23)
    at getTypeFromTypeNode (typescript/lib/_tsc.js:68622:12)
    at getAnnotatedAccessorType (typescript/lib/_tsc.js:62162:20)
    at getTypeOfAccessors (typescript/lib/_tsc.js:62180:99)
    at checkAccessorDeclarationDiagnostics (typescript/lib/_tsc.js:87089:26)

Any this nested inside the accessor's return type annotation triggers it too (get pair(): [this, string]). A method or property signature with the same this type is fine.

🙂 Expected behavior

No crash (5.9 checks this without errors).

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

Tái hiện crash bằng snippet của interface và các trường hợp accessor đã được báo cáo. Bắt đầu từ getAnnotatedAccessorType, getTypeOfAccessors và getConditionalFlowTypeOfType trong checker stack được báo cáo, sau đó xác định các source TypeScript tương ứng và thiết lập regression test. Hoàn tất khi các accessor này không còn gây crash và hành vi hiện có của 5.9 vẫn được một test bao phủ.

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ó
3/5
Thời gian dự kiến
1-2 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
68/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.