-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8e5028
commit 749b453
Showing
201 changed files
with
2,426 additions
and
2,231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
## [0.28.3](https://www.npmjs.com/package/@sinclair/typebox/v/0.28.3) | ||
|
||
## Overview | ||
|
||
Revision 0.28.3 adds a new Rest type to support variadic type composition. | ||
|
||
## Contents | ||
|
||
- Enhancements | ||
- [Variadic Types](#Variadic-Types) | ||
|
||
<a href="Variadic-Types"></a> | ||
|
||
## Variadic Types | ||
|
||
Revision 0.28.3 adds a new type named `Type.Rest`. This type is used to extract a tuple array of type of `[...TSchema]`. The return value of this type is not strictly JSON Schema, however the tuple array can be used as a parameter to other types that accept tuples as their arguments. | ||
|
||
### Tuple Concatenation | ||
|
||
```typescript | ||
// TypeScript | ||
|
||
type A = [1, 2] | ||
|
||
type B = [3, 4] | ||
|
||
type C = [...A, ...B] | ||
|
||
// TypeBox | ||
|
||
const A = Type.Tuple([Type.Literal(1), Type.Literal(2)]) | ||
|
||
const B = Type.Tuple([Type.Literal(3), Type.Literal(4)]) | ||
|
||
const C = Type.Tuple([...Type.Rest(A), ...Type.Rest(B)]) | ||
``` | ||
|
||
### Tuple To Parameter | ||
|
||
```typescript | ||
// TypeScript | ||
|
||
type P = [number, number] | ||
|
||
type F1 = (param: [...P]) => void | ||
|
||
type F2 = (param: [...P, number]) => void | ||
|
||
// TypeBox | ||
|
||
const P = Type.Tuple([Type.Number(), Type.Number()]) | ||
|
||
const F1 = Type.Function(Type.Rest(P), Type.Void()) | ||
|
||
const F2 = Type.Function([...Type.Rest(P), Type.Number()], Type.Void()) | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.