Fix incorrect tuple usage and syntax #21387
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Lots of packages use singleton tuple syntax in place of array syntax.
[number]
was previously almost compatible withnumber[]
, so it slipped through in a lot of places. Now, with fixed-length tuples, this reliably fails.The fixed-length tuple also found a couple of errors, in highchart and leaflet. I changed the highchart test to be correctly-typed, although the intent of the test is probably a bit changed. I am 99% sure the test is wrong, though, based on the highchart documentation.
The leaflet test assumes that
LatLng
marks whether altitude was provided in its type, which it does not, so converting aLatLng
returns[number, number] | [number, number, number]
, which was previously equivalent to[number, number]
.It's relatively simple to add a type parameter
LatLng<T extends number | undefined>
, but it's a big change that's outside the scope of this set of simple fixes.