3 reasons to use TypeScript instead of React PropTypes: When checks run: PT:...
3 reasons to use TypeScript instead of React PropTypes:
When checks run:
PT: Runtime 👎
TS: Compile time 👍
Where output displays:
PT: Browser console, when you run the component 👎
TS: Terminal and editor 👍
Autocomplete:
PT: Poor 👎
TS: Excellent 👍
#reactjs #typescript
3 Reasons to use PropTypes instead of TypeScript:
Learning curve:
PT: Low 👍
TS: High - especially if new to types 👎
Error messages:
PT: Clear, direct 👍
TS: Often intimidating, and hard to understand 👎
Implementation:
PT: Easy 👍
TS: Can be tricky 👎
#react #typescript
Summary: There are tradeoffs. Both remain great options.
My take:
I'm comfortable with TS, so I prefer its extra power.
But if your team doesn't know TS, doesn't have a history of working with types, or your team and app are smaller, PropTypes remain a great choice.
Oh, and I've shipped many large apps using PropTypes. The apps are reliable. We didn't struggle with PropTypes. They were sufficient.
But in retrospect, I suspect we'd have moved faster via compile-time checks on the large apps.
Compile-time checks tend to speed development.