Instantiation expression inside nested classes produces unexpected circular reference error
@jakebailey đang làm issue này rồi.
Từ ngày 22/2/2023.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Bug Report
🔎 Search Terms
instantiation expression nested class
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
Playground link with relevant code
💻 Code
class A<T = number> {
//static { type _<T extends A = A> = 0 }
//^ will work when uncomment it?
value!: T;
child!: InstanceType<typeof A.B<A<T>>>
static B = class B<T extends A = A> {
parent!: T;
}
}
var a = new A
a.child.parent.value
// ^?
🙁 Actual behavior
Shows an error 'child' is referenced directly or indirectly in its own type annotation..
However, when uncommenting // static {...} it will work only in playground.
In VSCode it still shows the error above.
🙂 Expected behavior
a.child.parent.value is number
Workaround
A workaround is remove the default type for class B<T>. The code below works well, also, only in playground. In my VSCode(5.0.0-dev.20230216) it still breaks unfortunately.
class A<T extends number = number> {
value!: T;
child!: InstanceType<typeof A.B<A<T>>>
static B = class B<T extends A> {
parent!: T;
}
}
var a = new A
a.child.parent.value
// ^? number
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.4k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 117
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/TypeScript
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
microsoft/TypeScript#64322 · 2 bình luận · 1 reaction · 2 người được giao ·
-
Possible Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/TypeScript#64278 · 1 bình luận · 1 reaction ·
-
Docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
microsoft/TypeScript#64118 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
microsoft/TypeScript#64094 ·
-
Docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
microsoft/TypeScript#63959 · 5 bình luận ·
Tất cả issue của microsoft/TypeScript
Issue tương tự
-
optimization optimization:agents-md-curator
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
githubnext/gh-aw-cao#13143 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
blinklabs-io/bursa#904 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 bình luận ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100