mirror of
https://github.com/zoriya/typebox.git
synced 2026-05-27 00:26:52 +00:00
Revision 0.31.14 (#584)
* Revert 0.31.8 Enum * Intercept for Enum on StaticDecode
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ import { Type } from '@sinclair/typebox'
|
||||
// expect empty enum to be string (as empty enums T[keyof T] evaluates as string)
|
||||
enum E {}
|
||||
const T = Type.Enum(E)
|
||||
Expect(T).ToStaticNever()
|
||||
Expect(T).ToStatic<string>()
|
||||
}
|
||||
{
|
||||
// expect empty enum to be never
|
||||
|
||||
@@ -78,9 +78,5 @@ import { Type, Static } from '@sinclair/typebox'
|
||||
C = 'Z',
|
||||
}
|
||||
const T = Type.Record(Type.Enum(E), Type.Number())
|
||||
Expect(T).ToStatic<{
|
||||
X: number
|
||||
Y: number
|
||||
Z: number
|
||||
}>()
|
||||
Expect(T).ToStatic<{}>()
|
||||
}
|
||||
|
||||
@@ -278,3 +278,16 @@ import { Expect } from './assert'
|
||||
Expect(T).ToStaticDecode<number>()
|
||||
Expect(GenericIntersect(T)).ToStaticDecode<1>()
|
||||
}
|
||||
{
|
||||
// should decode enum
|
||||
enum E {
|
||||
A,
|
||||
B,
|
||||
C,
|
||||
}
|
||||
const T = Type.Transform(Type.Enum(E))
|
||||
.Decode((value) => 1 as const)
|
||||
.Encode((value) => E.A)
|
||||
Expect(T).ToStaticDecode<1>()
|
||||
Expect(T).ToStaticEncode<E>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user