6 ms·
TypeScript never promised improving safety, maybe it’s a common misconception. But TypeScript has no runtime mode or information. You were always at the mercy o
by sdfhbdf 1y ago
TypeScript never promised improving safety, maybe it’s a common misconception. But TypeScript has no runtime mode or information. You were always at the mercy of running and not ignoring the typechecker. Nothing stopped you from running ts-node or tsx on code with egregious type errors. TypeScript is more like a linter in that regard.
- MrJohz 1y agoI think it's not fair to say that Typescript isn't about improving safety, just that the mechanism isn't the same as with other languages. Typescript had always allowed you to ignore the type checker (in fact, the default configuration will always attempt to emit compiled Javascript, even if the source Typescript has type errors). But if you run the type checker on every commit (via e.g. CI or a precommit hook), then you can be sure that the code you release is correctly typed, which will not guarantee it is safe, but makes it more likely. I agree that it's better to think of Typescript as a linter that needs specialised annotations to work, rather than a type system like you might find in Java or Rust.
- tkzed49 1y ago> TypeScript is more like a linter that's exactly the point--GP is pointing out that node can't do that part
- madeofpalk 1y agoWhich is why the title is "Node can now execute Typescript files" and not lint, check, or even run TypeScript files.
- ohmahjong 1y agoI'm not sure what the distinction between "execute" and "run" is; is there a difference?
- JoBrad 1y agoNode is just inline transpiling the TS into JS, then running the JS.
- primering 1y agoThis is misleading. It is not transpiling TS in JS, it is transpiling a subset of TS into JS. If my normal TS code can not be "executed" by Node, then it is not executing TS per definition but something else. If you are good with Node supporting and "executing" only a subset of TS and lacking useful features, that's fine. But don't tell people it is executing TypeScript. That's like me saying my rudimentary C++ compiler supports C++ while in reality only supporting 50%. People would be pissed if they figure it out once they try to run it on their codebase.
- Dylan16807 1y agoIt's quite close to 100%. It makes one extra-strictness toggle mandatory. Saying it's not TS is much more misleading.
- madeofpalk 1y agoNo, I don't think there really is. But to be execute is even more clear that it's just... executing the code, whereas I could maybe understand someone being confused that run implied some level of type checking.
- tempodox 1y ago> TypeScript never promised improving safety What, pray tell, would be the point of putting all that type information in there, and then have it checked (via tsc), if not for the sake of safety? What other use would this have in your opinion?