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
If fnOrConst is a function, its return value (type R) is returned, otherwise it is returned directly (type T).
This is true but TS doesn't have a concept of negated types today so it can't quite reason about the "else" branch of this.
This is an expected breaking change. It was announced here. Note that your code has never worked in a similar situation (that logical-wise is actually the same):
exporttypeReturnTypeOrStatic<T>=Textends(...args: any[])=> infer R
? R
: T;exportfunctionevalOrStatic2<T>(fnOrConst: T,
...args: any[]): ReturnTypeOrStatic<T>{if(typeoffnOrConst==="function"){returnfnOrConst(...args);}returnfnOrConst;// error}
π Search Terms
5.8, return, type
π Version & Regression Information
β― Playground Link
No response
π» Code
π Actual behavior
Error under
fnOrConst
at the end of the conditional:π Expected behavior
no error. If
fnOrConst
is a function, its return value (typeR
) is returned, otherwise it is returned directly (typeT
).Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: