3 ms·
> Typescript has this same problem Don’t most languages have the same problem? Even C or Rust have escape hatches that let you override compile-time type check
by School-Cotton 1y ago
> Typescript has this same problem
Don’t most languages have the same problem? Even C or Rust have escape hatches that let you override compile-time type checking and pass whatever gibberish you want to a function. How is Typescript any worse?
- b_e_n_t_o_n 1y agonode main.js just runs the code. you could simply not run tsc, which plenty of people do. can you ignore all type errors in Rust?
- nevir 1y agoThe Rust equivalent is more like using `unsafe` and derefing raw pointers
- b_e_n_t_o_n 1y agoYeah and you can explicitly assert a null is a string in TS, but it's explicit. You can't build a Rust program without those asserts but it's trivial to skip the type checking for TS which is more of a linter than a type system.
- chamomeal 1y agoI disagree that TS is more of a linter. But I definitely feel sympathetic to that perspective. I’ll pull off the cleanest, nicest generic constraints on some component that infers everything perfectly and doesn’t allow invalid inputs, just for a coworker to throw @ts-nocheck on the entire file. It hurts
- deleted 1y ago[deleted]
- IshKebab 1y agoYou can ignore the borrow checker at least by using mrustc. And some type checks at least could be optional. The fact that they aren't isn't really a fundamental property of Rust, it's just because it's easy to make them not optional. In my experience nobody writes Typescript without checking the types. Unlike Python for example where it's not uncommon to have broken types. (And it's way more of a mess in general.)
- School-Cotton 1y agoIf you don’t run tsc you are not really using typescript.