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
error TS2322: Type 'number' is not assignable to type 'true extends B ? number : number'.
return n;
~~~~~~~~~
In this practical example, there is a workaround, changing the return type to number | (true extends B ? null : never). But it was hard for me to figure out what was making TypeScript unhappy, since this seemed too simple an inference for TypeScript to miss.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 3.2.0-dev.20181004
Code
Expected behavior: Successful compilation
Actual behavior: I get the following error:
Playground Link: Link
Use case:
I wouldn't expect anybody to write the code above. Here's something more like my original example (link):
This gives the error
In this practical example, there is a workaround, changing the return type to
number | (true extends B ? null : never)
. But it was hard for me to figure out what was making TypeScript unhappy, since this seemed too simple an inference for TypeScript to miss.The text was updated successfully, but these errors were encountered: