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
However, the above is in error, as the type inferred for ...others is the empty object ({}). Thus the expression within the DIV tags gives the error Property 'anything' does not exist on type '{}'.
If I explicitly type the parameter then all is OK. Namely:
It seems to me that for the ease of writing (and porting existing code), ...others above should default to any, as other untyped parameters do.
This may have already been discussed in some of the other rest/spread discussions. I did trying to find a definitive explanation, but those threads were quite verbose. Apologies if already covered.
That's an oversight I think. The machinery that infers a contextual type for binding patterns needs to be updated for object rest so that it propagates the any through to `others`.
Using the latest release-2.1 branch, I'm seeing the following behavior.
I'm writing some React/JSX code, and using a pattern often seen in code in the wild, namely:
However, the above is in error, as the type inferred for
...others
is the empty object ({}
). Thus the expression within the DIV tags gives the errorProperty 'anything' does not exist on type '{}'
.If I explicitly type the parameter then all is OK. Namely:
It seems to me that for the ease of writing (and porting existing code),
...others
above should default toany
, as other untyped parameters do.This may have already been discussed in some of the other rest/spread discussions. I did trying to find a definitive explanation, but those threads were quite verbose. Apologies if already covered.
Ping @sandersn , @RyanCavanaugh , @mhegazy
The text was updated successfully, but these errors were encountered: