DEV Community

Discussion on: Notes on TypeScript: Inferring React PropTypes

Collapse
 
noriste profile image
Stefano Magni

Thank you for your amazing article!! 👏
One question: how do you manage callback props? The solution above does not help with them because the proptypes does not allow to manage them effectively. For example, I could have this ComponentProps type in my component

export interface ComponentProps {
  handleCheckboxChange: (id: string, checked: boolean) => void;
}

how could I update the InferPropTypes type to be prompted by TS if I pass a callback with a wrong signature?
Thank you so much

Collapse
 
busypeoples profile image
A. Sharif

Thanks for the kind words!
I will have a closer look tomorrow and try to provide more insights if possible.