We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is broken in 5.6, 5.7, and nightly at least.
https://www.typescriptlang.org/play/?target=99&ts=5.8.0-dev.20250117&ssl=6&ssc=12&pln=6&pc=15#code/IYIwzgLgTsDGEAJYBthjAgguacIGFV0AeAEQD4EBvAKAXoQHMBTRAE2AmAAoBKALgSlqdBmKisArlAB21AL4I0CSTIDWMgPYB3OctKj68moYSROAS1gIAHgE8AXsQAqCZjYjMZbDBDsAHZk0AMywcGHhCNDBiYBk7cnJuUzEIAAsLMEFnABoUhg4ubLcPLx8EP0CQsMgIgiIYixlg5ighSgB+IQRBGWYAN1bTXgUaYxoUaIR8TRlYCU8o9BLPbwxsWrwlmNqmxkpaMZMZuYXmbYA6ewduAEYAJgBmXiA
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)
The ConcreteClass.xyz results in Type instantiation is excessively deep and possibly infinite. and as a result infers D as never.
ConcreteClass.xyz
Type instantiation is excessively deep and possibly infinite.
D
never
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
InstanceType<T> extends AbstractClass<infer D> ? D : never
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
π Search Terms
π Version & Regression Information
This is broken in 5.6, 5.7, and nightly at least.
β― Playground Link
https://www.typescriptlang.org/play/?target=99&ts=5.8.0-dev.20250117&ssl=6&ssc=12&pln=6&pc=15#code/IYIwzgLgTsDGEAJYBthjAgguacIGFV0AeAEQD4EBvAKAXoQHMBTRAE2AmAAoBKALgSlqdBmKisArlAB21AL4I0CSTIDWMgPYB3OctKj68moYSROAS1gIAHgE8AXsQAqCZjYjMZbDBDsAHZk0AMywcGHhCNDBiYBk7cnJuUzEIAAsLMEFnABoUhg4ubLcPLx8EP0CQsMgIgiIYixlg5ighSgB+IQRBGWYAN1bTXgUaYxoUaIR8TRlYCU8o9BLPbwxsWrwlmNqmxkpaMZMZuYXmbYA6ewduAEYAJgBmXiA
π» Code
π Actual behavior
The
ConcreteClass.xyz
results inType instantiation is excessively deep and possibly infinite.
and as a result infersD
asnever
.π 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/IYIwzgLgTsDGEAJYBthjAgguacIGFV0AeAEQD4EBvAKAXoQHMBTRAE2AmAAoBKALgSlqdBmKisArlAB21AL4I0CSTIDWMgPYB3OctKj68moYSROAS1gIAHgE8AXsQAqCZjYjMZbDBDsAHZk0AMywcGHhCNDBiYBk7cnJuUzEIAAsLMEFnABoUhg4uQQBJGXMZWGZnAOYXSndPbwxsSAiCIhiLGWDmKCFKAH4hBEEZZgA3XtNeBRpjGhRohHxNColPKPQ3Dy8fMNa8TZjWrsZKWjmTFbXWZiOAOnsHbgBGACYAZl4gAAdditional information about the issue
No response
The text was updated successfully, but these errors were encountered: