PropTypes modifier issue

20 Views Asked by At

In React we implement component that has id as one of the props, id is optional:

import * as PropTypes from 'prop-types';


export interface ComponentA extends Omit<ComponentB, 'onDayClick'> {

// some props

/**
* The HTML ID for the entire ComponentA. This is also used for the ID of         
* subcomponents.
*/
id?: string;
}

Here we introduce a ComponentAPropTypes in order to be exported:

export const ComponentAPropTypes = {
  id: PropTypes.string,

  //other props

}
ComponentA.propTypes = ComponentAPropTypes;

When I hover ComponentAPropTypes I see that is applies Requirable modifier to id and other optional props as well:

const ComponentAPropTypes: {
 id: PropTypes.Requireable<string>;

}

how can I avoid it?

0

There are 0 best solutions below