Skip to content Skip to sidebar Skip to footer

Typescript: Type 'any' Is Not Assignable To Type 'never'

I have following type: export type FormField = { name: string; type: string; mandatory: boolean; options?: FormFieldOptionsType; visibleIfIndIsVisible?: number; ind?: n

Solution 1:

This would give you a union type containing all possible types inside FormField.

export function saveFormField<T extends keyof FormField>(
    key: T,  value: FormField[T]
){
    ...
}

Post a Comment for "Typescript: Type 'any' Is Not Assignable To Type 'never'"