Form Utilities (FormData, Sanitize, MergeForms)

Hard

Create a set of utility types for working with forms in React applications.

  • FormData<T> — makes all fields optional and adds isDirty
  • Sanitize<T, K> — removes specified keys and makes rest readonly
  • MergeForms<A, B> — merges forms: A required, B optional, common fields intersection

Examples:

Input 1: type Form = FormData<{ name: string }>
Output 1: { name?: string; isDirty: boolean }
Output
Run your code to see results.