While working with Typescript, I encountered an issue where I couldn't make a property not required when overwriting it. I have defined two interfaces:
interface IField {
label: string;
model: string;
placeholder?: string;
addon?: string;
showOn?: IDictionary <string | number>;
maxlength?: number;
}
interface ICheckboxField extends IField {
model?: string;
type: 'checkbox';
default?: string;
options: IOption[];
validation?: {
required?: string;
};
}
In the ICheckboxField interface, I tried to set the model property as not required. However, all other fields that extend from IField require a mandatory model.
I am curious if this limitation is inherent to Typescript or if there is a workaround besides avoiding extending the interface and manually adding specific properties for each interface?