This commit is contained in:
sinclair
2025-12-24 15:44:34 +09:00
commit 13d553220c
1047 changed files with 80931 additions and 0 deletions

49
test/static/optional.ts Normal file
View File

@@ -0,0 +1,49 @@
import { Expect } from './assert'
import { Type, Static } from '@sinclair/typebox'
{
const T = Type.Object({
A: Type.Optional(Type.String()),
})
type T = Static<typeof T>
Expect(T).ToStatic<{
A?: string
}>()
}
// Noop
// prettier-ignore
{
const T = Type.Object({
A: Type.Optional(Type.String(), false),
})
type T = Static<typeof T>
Expect(T).ToStatic<{
A: string
}>()
}
// Additive
// prettier-ignore
{
const T = Type.Object({
A: Type.Optional(Type.String(), true),
})
type T = Static<typeof T>
Expect(T).ToStatic<{
A?: string
}>()
}
// Subtractive
// prettier-ignore
{
const T = Type.Object({
A: Type.Optional(Type.Optional(Type.String()), false)
})
type T = Static<typeof T>
Expect(T).ToStatic<{
A: string
}>()
}