Open
Description
π Search Terms
class inference, optional class, broken inference
π Version & Regression Information
This changed in PR #31116
However, this was the first time that there was even a distinction between a generic and non-generic class during inference to my knowledge. This likely means this has existed ever since the ability to infer a generic class has existed.
β― Playground Link
π» Code
type AnyConstructor = new (...args: any[]) => object;
function RenderFlagsMixin<BaseClass extends AnyConstructor | undefined = undefined>(
Base?: BaseClass,
) {};
class Container<T> {}
// ^ Only happens when the class is generic.
RenderFlagsMixin(Container)
// ^ Argument of type 'typeof Container' is not assignable to parameter of type 'undefined'.
π Actual behavior
BaseClass
is inferred as undefined
despite the call being the value Container
.
π Expected behavior
BaseClass
should be inferred as typeof Container
.
Additional information about the issue
No response