Expanding `FieldBag` and `useForm`
AntanasGa opened this issue · comments
AntanasGa commented
Overview
When working on projects i expect some types to be shared between back end and front end, meaning that if i want the type to change in one, I'll have to check over the other.
the suggested changes would be:
export function useForm<
T extends object,
V extends FieldBag = T extends FieldBag
? T
: {
[K in keyof T]: FieldOutput<T[K]>;
},
>({
fields,
onSubmit,
makeCleanAfterSubmit,
}: FormWithoutDynamicListsInput<V>): Form<V>;
export type FieldOutput<T> = T extends object
? T extends any[]
? FieldDictionary<T>[]
: FieldDictionary<T>
: Field<T>;
Type
- New feature
- Changes to existing features