π Search Terms
InstanceType | undefined collapses to InstanceType
π Version & Regression Information
Tested with typescript 5.9.3
β― Playground Link
No response
π» Code
class Foo {
static async test<TThis extends typeof Foo>(
this: TThis
): Promise<InstanceType<TThis> | undefined> {
return undefined
}
}
async function test() {
const x = await Foo.test()
}
π Actual behavior
type of x resolves to Foo, when it should resolve to Foo | undefined. The same happens with null
π Expected behavior
It should have been resolved to Foo | undefined.
Additional information about the issue
No response