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
Copy file name to clipboardexpand all lines: readme.md
+27-14
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,7 @@ License MIT
83
83
- [Conditional](#types-conditional)
84
84
- [Template](#types-template-literal)
85
85
- [Indexed](#types-indexed)
86
-
- [Variadic](#types-variadic)
86
+
- [Rest](#types-rest)
87
87
- [Guards](#types-guards)
88
88
- [Unsafe](#types-unsafe)
89
89
- [Strict](#types-strict)
@@ -872,30 +872,43 @@ const A = Type.Index(T, ['x']) // type A = T['x']
872
872
873
873
constB=Type.Index(T, Type.KeyOf(T)) // type B = T[keyof T]
874
874
```
875
-
<a name='types-variadic'></a>
875
+
<a name='types-rest'></a>
876
876
877
-
### Variadic Types
877
+
### Rest Types
878
878
879
-
Variadic types are supported with `Type.Rest`. This type will extract interior types from a tuple and return them as a flat array. This array can then be passed to other types that accept arrays as arguments.
880
-
881
-
The following creates variadic functions using the Rest type.
879
+
Rest parameters are supported with `Type.Rest`. This function is used to extract interior arrays from tuples to allow them to compose with the JavaScript spread operator `...`. This type can be used for tuple concatination and variadic function composition.
882
880
883
881
```typescript
884
882
// TypeScript
885
883
886
-
typeP= [number, number]
884
+
typeT= [number, number] // type T = [number, number]
887
885
888
-
typeF1=(param:[...P]) =>void
886
+
typeC= [...T, number] // type C = [number, number, number]
0 commit comments