The Optional function applies an optional ? modifier to a type.
Example usage is shown below.
const T = Type.Object({ // const T = {
x: Type.Optional(Type.Number()), // type: 'object',
y: Type.Optional(Type.Number()), // required: ['z'],
z: Type.Number() // properties: {
}) // x: { type: 'number', '~optional': true },
// y: { type: 'number', '~optional': true },
// z: { type: 'number' }
// }
// }
type T = Static<typeof T> // type T = {
// x?: number,
// y?: number,
// z: number
// }
Use the IsOptional function to guard values of this type.
const checked = Type.IsOptional(value) // value is TOptional