Hacker News new | past | comments | ask | show | jobs | submit login

Not necessarily - you could be parsing a JSON API response or something.



If you don't trust your JSON input to be of proper type, you should validate its type immediately when you receive it, before you start fanning it out to your code. Spreading this work to prop types just makes it harder to keep track of it, and harder to find the source of the problem.

Besides, some of that broken JSON data might never even be passed through proptypes (e.g. if that data lives only in a component's state).

Also, there are compile-time solutions to this in some compile-to-JS languages, e.g. like https://github.com/lihaoyi/autowire for Scala.js




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: