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
False negatives when destructuring an array of explicit length #21220
Expected behavior:
TypeScript knows that has4 has 4 members and has2 has 2 members; it can infer that takes4's signature will be satisfied by either call.
Actual behavior:
Expected 4 arguments, but got a minimum of { number of explicit arguments } for each call to takes4.
Related:
I discovered this when I was trying to pass a deconstruction to bezier-js.Bezier's constructor. The actual error I'm getting is that my first explicit argument ({ x: 0, y: 0 }) is not assignable to the type number. I'm presuming that TS is choosing the wrong overload because it can't deduce that destructuring fulfills one of the overloads.
The code I wrote in my codebase was destructuring an argument of the type [Point2D, Point2D]. I used literals in the reduction for simplicity, but I saw this bug with an explicit type too.
Activity
mhegazy commentedon Jan 17, 2018
duplicate of #4130
also note that fixed length arrays (or tuples) are not inferred by default, an explicit type annotation is still required.
appsforartists commentedon Jan 17, 2018
The code I wrote in my codebase was destructuring an argument of the type
[Point2D, Point2D]. I used literals in the reduction for simplicity, but I saw this bug with an explicit type too.