keajs / kea-forms

MIT License
3 stars 3 forks source link

Manual Type Creation #4

Open Tbhesswebber opened 10 months ago

Tbhesswebber commented 10 months ago

Typegen isn't working (particularly in a Code Sandbox where it wasn't worth setting it up), but I can't quite figure out the way that I should be constructing the type for my logic. I dug through types.ts to see if there was something along the lines of MakeFormLogicType<TInputs, TValues, TActions, TProps> = MakeLogicType<FormValues<TInputs> & TValues, FormActions<TInputs> & TActions, TProps>. There's nothing that I've seen in any documentation and the types file doesn't have anything that obviously attempts to solve this problem - is there a recommended path forward here?

mariusandra commented 10 months ago

Such FormActions<> and FormValues<> types seem like the right approach, but sadly they don't exist 😅

With modern TS template literal types and support for things like Capitalize<T>, I believe such types are very doable. You can probably generate all the required values and actions this way from just the form name and the default fields.