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
Here we used [a destructuring pattern](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) for `paintShape`'s parameter, and provided [default values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Default_values) for `xPos` and `yPos`.
177
177
Now `xPos` and `yPos` are both definitely present within the body of `paintShape`, but optional for any callers to `paintShape`.
178
178
179
-
<aside>
180
-
Note that there is currently no way to place type annotations within destructuring patterns.
181
-
This is because the following syntax already means something different in JavaScript.
182
-
</aside>
179
+
> Note that there is currently no way to place type annotations within destructuring patterns.
180
+
> This is because the following syntax already means something different in JavaScript.
183
181
184
182
```ts twoslash
185
183
// @noImplicitAny: false
@@ -726,14 +724,11 @@ function doSomething(stringHash: [string, number]) {
726
724
}
727
725
```
728
726
729
-
<aside>
730
-
Tuple types are useful in heavily convention-based APIs, where each element's meaning is "obvious".
731
-
This gives us flexibility in whatever we want to name our variables when we destructure them.
732
-
In the above example, we were able to name elements `0` and `1` to whatever we wanted.
733
-
734
-
However, since not every user holds the same view of what's obvious, it may be worth reconsidering whether using objects with descriptive property names may be better for your API.
735
-
736
-
</aside>
727
+
> Tuple types are useful in heavily convention-based APIs, where each element's meaning is "obvious".
728
+
> This gives us flexibility in whatever we want to name our variables when we destructure them.
729
+
> In the above example, we were able to name elements `0` and `1` to whatever we wanted.
730
+
>
731
+
> However, since not every user holds the same view of what's obvious, it may be worth reconsidering whether using objects with descriptive property names may be better for your API.
737
732
738
733
Other than those length checks, simple tuple types like these are equivalent to types which are versions of `Array`s that declare properties for specific indexes, and that declare `length` with a numeric literal type.
0 commit comments