Closed ngoctuan001 closed 3 years ago
This repo does not provide types, so this isn't an issue with this repo - perhaps with the DT types.
Specifically, though, all PropTypes are optional unless you append .isRequired
to them. iow:
InputNumberAutoSizeComponent.propTypes = {
className: PropTypes.oneOfType([
PropTypes.string.isRequired,
PropTypes.arrayOf(PropTypes.string.isRequired)
].isRequired),
};
I'm writing react typescript and have problem with optional prop-types check. Below is my code:
Somehow my typescript throw error in className when declare like this. Here is the error:
This looks weird because as I read in the documents, the prop-types should be optional and accept undefined. Anyone know how to fix this, thanks.
Version: 15.7.3 "typescript": "^3.4.2"
Update: I think the problem come from PropTypes.arrayOf(PropTypes.string). The arrayOf cause the error.