We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
method conditional return type not assignable to type
3.3.3+
Playground link with relevant code
export interface Foo<T> {} export class Foo<T> { public bar(): T extends string ? string | number : number { return 1; } }
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.
interface Foo
Return statement is not an error, because 1 is assignable to both string | number and number.
1
string | number
number
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
π Actual behavior
Return statement is an error, despite being valid for both branches of the conditional return type.
This ONLY happens if the
interface Fooexists. If the interface is commented out, the error goes away.π Expected behavior
Return statement is not an error, because
1is assignable to bothstring | numberandnumber.