RecordPropsType
See source codeExtracts the TypeScript types from a record properties configuration.
Takes a configuration object where values are validators and returns the corresponding TypeScript types, with undefined values made optional.
type RecordPropsType<Config extends Record<string, T.Validatable<any>>> =
MakeUndefinedOptional<{
[K in keyof Config]: T.TypeOf<Config[K]>
}>
Example
const shapePropsConfig = {
width: T.number,
height: T.number,
color: T.optional(T.string),
}
type ShapeProps = RecordPropsType<typeof shapePropsConfig>
// Result: { width: number; height: number; color?: string }
Prev
RecordPropsNext
SetValue