In my coding project, I have a Button class that implements the IButton interface.
class Button implements IButton {
public fit = 'medium';
}
declare type Fit = 'small' | 'medium' | 'large';
export interface IButton {
fit: Fit;
}
Despite setting 'medium' as the default value for the fit property in the Button class, TypeScript throws an error indicating that it is not assignable to type Fit.
Property 'fit' in type 'Button' is not assignable to the same property in base type 'IButton'.
Type 'string' is not assignable to type 'Fit'.
Is there an alternative approach to achieve this functionality?