From 442dd4988608f982227d1aab0537b2d711ba0f3e Mon Sep 17 00:00:00 2001 From: anlonely Date: Sun, 6 Dec 2026 04:28:22 +0800 Subject: [PATCH] Explain labeled tuple elements in the Handbook --- packages/documentation/copy/en/handbook-v2/Object Types.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/documentation/copy/en/handbook-v2/Object Types.md b/packages/documentation/copy/en/handbook-v2/Object Types.md index d45163830fc8..8ace4214542e 100644 --- a/packages/documentation/copy/en/handbook-v2/Object Types.md +++ b/packages/documentation/copy/en/handbook-v2/Object Types.md @@ -942,9 +942,12 @@ function doSomething(pair: [string, number]) { ``` We can also [destructure tuples](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Array_destructuring) using JavaScript's array destructuring. +The labels `text` and `hash` in the example below describe each position in editor hints. +The tuple still accepts the same values as `[string, number]`. +Since TypeScript 5.2, we can also label just some elements, as in `[string, hash: number]`. ```ts twoslash -function doSomething(stringHash: [string, number]) { +function doSomething(stringHash: [text: string, hash: number]) { const [inputString, hash] = stringHash; console.log(inputString);