I am using an interface with multiple properties. But in a couple of them, I use any | null, since, the value can be omitted at points.
Example:
export default interface IField {
fieldName: string;
fieldType: string;
fieldLabel: string;
fieldPlaceholder: string;
fieldDefaultValue?: any | null; // Transform to Generic
isHelpAvailable?: string | ReactNode;
isFieldRequired: boolean;
isFieldValidated?: Function | boolean;
}
It was proposed to me, to try and use Generics is cases like that. But I haven't used them in the past. Could you please, transform this one for me, as a guide, with a small explanation, on what is going on.
I am using the same pattern in multiple places, but right now, don't know how to tackle them. Thanks!!