4 ms·
>there's zero technical difference between TypeScript types and a combination of default args and type checker functions I may be missing something, but aren't
by dmux 3y ago
>there's zero technical difference between TypeScript types and a combination of default args and type checker functions
I may be missing something, but aren't your type checker functions called at runtime whereas Typescript would be doing static type checking at compile time?
- sibeliuss 3y agoYes, you are correct. It is clear the OP doesn't understand the purpose of typescript.
- rglover 3y agoI understand perfectly, but in practice I don't think the benefits outweigh the costs.
- rglover 3y agoThey are, but in practice there's little difference in the ends because you're getting the same feedback (did I pass the right type, yes or no). Like calling someone on a cell phone vs. a land line. If the type of data you're passing around is erratic beyond development (where, just like TypeScript, a function-based approach illuminates incorrect data being passed around), you're writing bad code and TypeScript is nothing more than a crutch. I expect most hardline TypeScript people to disagree, but type errors are the least of my concerns thanks to the above approach. It's not just an opinion; it's based on experience/evidence [1]. [1] https://github.com/cheatcode/joystick https://github.com/cheatcode/joystick