Native Typescript enum support
Author: 03xb7Created Jan 4, 2022Updated Jun 16, 2026
Labelsfeature
Hello, is there a way to express that some struct field must be of a given TS enum type ?
enum MyEnum {
Value1 = 'val1',
Value2 = 'val2',
}
const MyStruct = object({
// Something like this:
myEnum: nativeEnum(MyEnum)
})
// Here the MyStruct type would have a myEnum key of type MyEnum
type MyStruct = Infer<typeof MyStruct>;Thanks
Source: ianstormtaylor/superstruct