Revision 0.31.9 (#570)

This commit is contained in:
sinclairzx81
2023-09-03 23:47:17 +09:00
committed by GitHub
parent 224a4bee5b
commit 2b83dc6ad2
4 changed files with 79 additions and 12 deletions
+31 -1
View File
@@ -1,7 +1,8 @@
import { Expect } from './assert'
import { Type, Static } from '@sinclair/typebox'
import { Type } from '@sinclair/typebox'
{
// expect all variants
enum E {
A,
B = 'hello',
@@ -10,3 +11,32 @@ import { Type, Static } from '@sinclair/typebox'
const T = Type.Enum(E)
Expect(T).ToStatic<E.A | E.B | E.C>()
}
{
// expect all variants
const T = Type.Enum({
A: 1,
B: 2,
C: 3,
})
Expect(T).ToStatic<1 | 2 | 3>()
}
{
// expect variant overlap to reduce
const T = Type.Enum({
A: 1,
B: 2,
C: 2, // overlap
})
Expect(T).ToStatic<1 | 2>()
}
{
// expect empty enum to be never
enum E {}
const T = Type.Enum(E)
Expect(T).ToStaticNever()
}
{
// expect empty enum to be never
const T = Type.Enum({})
Expect(T).ToStaticNever()
}
+2 -2
View File
@@ -6,10 +6,10 @@ import './bigint'
import './boolean'
import './capitalize'
import './composite'
import './date'
import './constructor-parameters'
import './constructor'
import './emum'
import './date'
import './enum'
import './extract'
import './exclude'
import './function'