mirror of
https://github.com/zoriya/typebox.git
synced 2026-06-01 18:45:32 +00:00
Revision 0.32.9 (#731)
* Optimize Composite * Set and Composite Tests * Version
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Expect } from './assert'
|
||||
import { Type, TObject, TIntersect, TNumber, TBoolean } from '@sinclair/typebox'
|
||||
import { Type, TOptional, TObject, TIntersect, TNumber, TBoolean } from '@sinclair/typebox'
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Overlapping - Non Varying
|
||||
@@ -127,3 +127,60 @@ import { Type, TObject, TIntersect, TNumber, TBoolean } from '@sinclair/typebox'
|
||||
Type.Object({ x: Type.Boolean() })
|
||||
])
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Intersect
|
||||
// ------------------------------------------------------------------
|
||||
// prettier-ignore
|
||||
{
|
||||
const T: TObject<{
|
||||
x: TNumber;
|
||||
y: TNumber;
|
||||
z: TNumber;
|
||||
}> = Type.Composite([
|
||||
Type.Intersect([
|
||||
Type.Object({ x: Type.Number() }),
|
||||
Type.Object({ y: Type.Number() }),
|
||||
]),
|
||||
Type.Intersect([
|
||||
Type.Object({ z: Type.Number() })
|
||||
])
|
||||
])
|
||||
}
|
||||
// prettier-ignore
|
||||
{
|
||||
const T: TObject<{
|
||||
x: TIntersect<[TNumber, TNumber]>;
|
||||
y: TIntersect<[TNumber, TNumber]>;
|
||||
}> = Type.Composite([
|
||||
Type.Intersect([
|
||||
Type.Object({ x: Type.Number() }),
|
||||
Type.Object({ y: Type.Number() }),
|
||||
]),
|
||||
Type.Intersect([
|
||||
Type.Object({ x: Type.Number() }),
|
||||
Type.Object({ y: Type.Number() }),
|
||||
])
|
||||
])
|
||||
}
|
||||
// prettier-ignore
|
||||
{
|
||||
const T: TObject<{
|
||||
x: TIntersect<[TNumber, TNumber]>;
|
||||
}> = Type.Composite([
|
||||
Type.Intersect([
|
||||
Type.Object({ x: Type.Optional(Type.Number()) }),
|
||||
Type.Object({ x: Type.Number() }),
|
||||
])
|
||||
])
|
||||
}
|
||||
// prettier-ignore
|
||||
{
|
||||
const T: TObject<{
|
||||
x: TOptional<TIntersect<[TNumber, TNumber]>>;
|
||||
}> = Type.Composite([
|
||||
Type.Intersect([
|
||||
Type.Object({ x: Type.Optional(Type.Number()) }),
|
||||
Type.Object({ x: Type.Optional(Type.Number()) }),
|
||||
])
|
||||
])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user