You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeTest<T>=Textendsstring ? number : boolean;functionfoo<T>(x: T): Test<T>{if(typeofx==="string"){return5;}returntrue;}
π Actual behavior
Both branches have different flavors of error 2322
π Expected behavior
the typeof guard should have let Typescript know it was dealing with a string and should have now which branch of the conditional type it should be allowed to return. The same outside of the type guard since it returns and control flow analysis should have treated that like an implicit else.
The text was updated successfully, but these errors were encountered:
Bug Report
π Search Terms
conditional return type alias generics
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Both branches have different flavors of error 2322
π Expected behavior
the typeof guard should have let Typescript know it was dealing with a string and should have now which branch of the conditional type it should be allowed to return. The same outside of the type guard since it returns and control flow analysis should have treated that like an implicit else.
The text was updated successfully, but these errors were encountered: