facebook / prop-types

Runtime type checking for React props and similar objects
MIT License
4.48k stars 356 forks source link

How can i constrain func params? #208

Closed YouCii closed 6 years ago

YouCii commented 6 years ago
onCheckChange={(isChecked) => this.props.onCheckChange(isChecked)}

SettingItem.propTypes = {
    onCheckChange: PropTypes.func
};

It's not enough to constrain the 'onCheckChange' without parms-limit. Maybe I express my needs clearly.

ljharb commented 6 years ago

There's not really a way to do it with JS (without layering a type system on top).

Since propTypes are run on the prop value - which doesn't provide any information about what arguments it's going to eventually be called with - it's basically impossible to check this with propTypes.

YouCii commented 6 years ago

emmming, a little pity. Thanks for your reply @ljharb