Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| note:tue_jun_17_2025 [2025/06/17 08:48] – root1 | note:tue_jun_17_2025 [2025/06/17 13:00] (current) – [dokuwiki docker upgrade] lingao | ||
|---|---|---|---|
| Line 95: | Line 95: | ||
| </ | </ | ||
| + | ===== Tuple Map ===== | ||
| + | we can use mapped types for creating tuples. It's because tuple properties are indexes. | ||
| + | |||
| + | <code typescript> | ||
| + | type A<T extends unknown[]> | ||
| + | [P in keyof T] : T[P] | ||
| + | } | ||
| + | |||
| + | type a = A< | ||
| + | // ^ type a = [1, 2, 3] | ||
| + | </ | ||