I have a function with optional parameters that I pass down to another component.
update = (flag: boolean = true): void => {
// ...
}
In the component that I pass this down to, I have a field called updateFunc that I want to assign this function. What should be the type of this field?
What I Tried
If I define the field like the following, I cannot call it with a parameter.
updateFunc: () => void;
If I define the field like the following, I cannot call it without a parameter.
updateFunc: (flag: boolean) => void;
If I define the field like the following, I lose the type safety.
updateFunc: any;
updateFunc: (flag?: boolean) => void;?