Skip to content

FormBindingMethods

FormBindingMethods<T, Bindings, Overrides> = { [K in keyof Bindings]: K extends keyof Overrides ? Overrides[K] : FormBindingMethod<T, Bindings[K]> }

Defined in: binding.ts:193

Bind methods for the binding classes passed to extendFormBinding()

Form is extended with it to type the methods that extendFormBinding() adds.

T

The subject of the form

Bindings extends { [K in keyof Bindings]: FormBindingConstructor }

Type of the binding classes by method name, as passed to extendFormBinding()

Overrides extends { [K in keyof Overrides]: K extends keyof Bindings ? IsIdentical<ErasedSignature<Overrides[K]>, ErasedSignature<FormBindingMethod<T, Bindings[K]>>> extends true ? FormBindingMethod<T, Bindings[K]> : "override diverges from the binding" : "no binding for this override" } = Record<never, never>

Methods written by hand, by method name

export const myBindings = extendFormBinding({
bindDropdown: DropdownBinding,
});
declare module "@mobx-sentinel/form" {
interface Form<T> extends FormBindingMethods<T, typeof myBindings> {}
}

Each method is derived from its binding class (see FormBindingMethod), except for the methods written by hand in Overrides.

A generic binding class needs an override to keep its type parameters, which the derivation replaces with their constraints. An override may differ from the derived method only in having type parameters of its own: with them replaced by their constraints, it must be identical to the derived method. Writing the config with the binding's own types (e.g. RadioGroupBinding.Config<V>) keeps it in step with the class.