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
{{ message }}
Repository navigation
Ability to skip elements in tuple type annotation #2671
We had a question when discussing this issue -- what are the kinds of cases where the inferred type is "not correct" ? In other words, what's the value of writing these annotations vs letting them be inferred?
Sorry for the delay with answer. This question is just about consistency: JavaScript allows empty items and elision in many syntax elements. If it's allowed for array literals, why not to allow it for type annotations? Nothing critical here if the existing behaviour will remain. Just a "why not" thing. :)
Activity
DanielRosenwasser commentedon Apr 8, 2015
If I took your example and later added
xas in the following:What is the desired behavior?
zhuravlikjb commentedon Apr 8, 2015
I suppose that x here should have type of right-hand-side[0], or 'any', if the right-hand-side is absent.
Exactly the same way as for ordinary type annotations, when they are omitted:
var x = 0=> x: numbervar x=> x: anyThe same in the case of non-destructuring declarations:
RyanCavanaugh commentedon Apr 20, 2016
We had a question when discussing this issue -- what are the kinds of cases where the inferred type is "not correct" ? In other words, what's the value of writing these annotations vs letting them be inferred?
RyanCavanaugh commentedon Jun 13, 2016
Anton Lobov (@zhuravlikjb) any thoughts on the above question?
zhuravlikjb commentedon Jul 4, 2016
Sorry for the delay with answer. This question is just about consistency: JavaScript allows empty items and elision in many syntax elements. If it's allowed for array literals, why not to allow it for type annotations? Nothing critical here if the existing behaviour will remain. Just a "why not" thing. :)
RyanCavanaugh commentedon Sep 28, 2016
Doesn't seem to be a lot of desire for this in practice, plus it introduces new weird cases as Daniel pointed out.