Open
Description
Bug Report
π Search Terms
method conditional return type not assignable to type
π Version & Regression Information
3.3.3+
β― Playground Link
Playground link with relevant code
π» Code
export interface Foo<T> {}
export class Foo<T> {
public bar(): T extends string ? string | number : number {
return 1;
}
}
π Actual behavior
Return statement is an error, despite being valid for both branches of the conditional return type.
This ONLY happens if the interface Foo
exists. If the interface is commented out, the error goes away.
π Expected behavior
Return statement is not an error, because 1
is assignable to both string | number
and number
.