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
The shouldWorkButDoesNot function has a type error. It shouldn't have a type error because no matter what o.type is, ...o.data will always include the required props.
The function below (worksButSoUnnecessary ) works by type checking o.type, but since both parts of the ternary are exactly the same, the type checking is completely useless. However, it still needed?? for there to not be any typescript errors.
π Expected behavior
The function shouldWorkButDoesNot should not have an error.
The text was updated successfully, but these errors were encountered:
See #30581; o.type and o.data are correlated in a way the compiler does not understand unless you walk it through the different cases via control flow analysis.
Bug Report
π Search Terms
unnecessary type checking
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
The
shouldWorkButDoesNot
function has a type error. It shouldn't have a type error because no matter whato.type
is,...o.data
will always include the required props.The function below (
worksButSoUnnecessary
) works by type checkingo.type
, but since both parts of the ternary are exactly the same, the type checking is completely useless. However, it still needed?? for there to not be any typescript errors.π Expected behavior
The function
shouldWorkButDoesNot
should not have an error.The text was updated successfully, but these errors were encountered: