Static method on abstract class with generic this parameter causes "excessively deep" error when called on concrete classΒ #60992
Open
Description
π Search Terms
- abstract class
- static method
- this parameter
- excessively deep
- concrete class
- generic
π Version & Regression Information
This is broken in 5.6, 5.7, and nightly at least.
β― Playground Link
π» Code
abstract class AbstractClass<D> {
get data(): D {
return {} as unknown as D
}
static xyz<T extends typeof AbstractClass<any>>(
this: T,
data: T extends typeof AbstractClass<infer D> ? D : never
) {}
}
class ConcreteClass extends AbstractClass<string> {
}
ConcreteClass.xyz(123)
π Actual behavior
The ConcreteClass.xyz
results in Type instantiation is excessively deep and possibly infinite.
and as a result infers D
as never
.
π Expected behavior
This to work fine. A similar case, but where InstanceType<T> extends AbstractClass<infer D> ? D : never
works fine: https://www.typescriptlang.org/play/?target=99&ts=5.8.0-dev.20250117#code/IYIwzgLgTsDGEAJYBthjAgguacIGFV0AeAEQD4EBvAKAXoQHMBTRAE2AmAAoBKALgSlqdBmKisArlAB21AL4I0CSTIDWMgPYB3OctKj68moYSROAS1gIAHgE8AXsQAqCZjYjMZbDBDsAHZk0AMywcGHhCNDBiYBk7cnJuUzEIAAsLMEFnABoUhg4uQQBJGXMZWGZnAOYXSndPbwxsSAiCIhiLGWDmKCFKAH4hBEEZZgA3XtNeBRpjGhRohHxNColPKPQ3Dy8fMNa8TZjWrsZKWjmTFbXWZiOAOnsHbgBGACYAZl4gA
Additional information about the issue
No response
Metadata
Assignees
Labels
No labels