Hi, i think that ability to describe react component props as type with non required fields but it can be required if another field exists. For instance:
interface ComponentProps {
sortable?: boolean
onSortHandler - this field must be required only when sortable is true moreover it must don't exists in this interface
}
So, is it possible to do with conditional types ? For now i couldn't implement it
You don't need conditional types. Some like that should work:
type ComponentProps = {
sortable: true,
onSortHandler: any, // set the correct type
} | {
sortable?: false | null,
};
NOTE: better ask questions to stackoverflow.
@j-oliveras
Oh, sorry. Thank you very much.. My its my blame
Most helpful comment
You don't need conditional types. Some like that should work:
NOTE: better ask questions to stackoverflow.