Microsoft/TypeScript
GitHub ã§èŠãOverload order affects assignability of abstract constructors overloaded with regular constructors in interfaces
Open
#59,890 opened on 2024幎9æ7æ¥
BugDomain: IntersectionHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
abstract constructors, constructor overloading, overload order, intersection, type aliases, interfaces, assignability
ð Version & Regression Information
- This seems like a bug
- This is the behavior in every version I tried since abstract constructors were added (4.2)
⯠Playground Link
ð» Code
type C1 = abstract new (a: 1) => 1
type C2 = new (a: 2) => 2
interface A extends C1, C2 {} // Error: Cannot assign an abstract constructor type to a non-abstract constructor type.
interface B extends C2, C1 {} // Ok
declare let a: A
declare let b: B
// These are both effectively abstract
new a(1), new a(2), new b(1), new b(2)
a = b // Ok
b = a // Error: Cannot assign an abstract constructor type to a non-abstract constructor type.
type AbstractFirst = C1 & C2
type AbstractLast = C2 & C1
declare let abstractFirst: AbstractFirst
declare let abstractLast: AbstractLast
// These are assignable to each oher
abstractFirst = abstractLast
abstractLast = abstractFirst
b = abstractFirst // Error: Cannot assign an abstract constructor type to a non-abstract constructor type.
abstractFirst = b // Ok
b = abstractLast // Ok
abstractLast = b // Ok
ð Actual behavior
It seems that interfaces with both abstract and regular constructor overloads are only assignable from types with non-abstract first constructor overload.
ð Expected behavior
I don't expect any difference here.
Additional information about the issue
No response