|
|
|
|
|
by dartos
632 days ago
|
|
That’s not a good reason. Especially in our world where strong typing is something preferable. Fewer characters at the cost of clarity is poor api design.
Implicitness is almost always worse than explicitness. Explicit !== clumsy And again, almost nothing else in the js ecosystem behaves like this. Especially at the time of the big hooks update to react. Also, again, it’s not a tuple. It’s an array with 2 elements. JavaScript does not have tuples or the semantics for interacting with them as such.
You just need to know that there’s always going to be 2 elements. That extra knowledge burden is the hallmark of poor api design. |
|
Not true. In TypeScript, there are tuples — you can perfectly describe an array having 2 elements with different types, and even give names to them:
We use it all the time for simple 2-element thingies. You can say JavaScript isn't TypeScript, but cmon, just everybody out there uses TypeScript, it is the basic norm nowadays. So we're really talking about TypeScript semantics here.Also, even JS uses tuples for its core APIs. Enter `Object.entries` and `Object.fromEntries` — they operate on kv-pairs in form of 2-element arrays. So your assertion that tuples are something alien to JS ecosystem isn't accurate simply because of that.