▲ | 8n4vidtmkvmk 3 days ago | |||||||||||||
Everyone seems hung up on the type system, but I think the validity of the data is the important part. I'd still want to convert strings to ints, trim whitespace, drop extraneous props and all of that jazz even if I was using plain JS without types. I still wouldn't need to check the inputs again because I know it's already been processed, even if the type system can't help me. | ||||||||||||||
▲ | dwattttt 3 days ago | parent | next [-] | |||||||||||||
The type isn't just there to make it easy to understand when you do it, it's for you a year later when you need to make a change further inside a codebase, far from where it's validated. Or for someone else who's never even seen the validation section of code. I'm hung up on the type system because it's a great way to convey the validity of the data; it follows the data around as it flows through your program. I don't (yet) Typescript, but jsdoc and linting give me enough type checking for my needs. | ||||||||||||||
| ||||||||||||||
▲ | Lvl999Noob 3 days ago | parent | prev [-] | |||||||||||||
Pure js without typescript also has "types". Typescript doesn't give you nominal types either. It's only structural. So when you say that you "know it's already been processed", you just have a mental type of "Parsed" vs "Raw". With a type system, it's like you have a partner dedicated to tracking that. But without that, it doesn't mean you aren't doing any parsing or type tracking of your own. | ||||||||||||||
|