Remix.run Logo
sdfhbdf 5 days 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 5 days ago | parent | next [-]

I 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.

tempodox 4 days ago | parent | prev | next [-]

> 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?

tkzed49 5 days ago | parent | prev [-]

> TypeScript is more like a linter

that's exactly the point--GP is pointing out that node can't do that part

madeofpalk 5 days ago | parent [-]

Which is why the title is "Node can now execute Typescript files" and not lint, check, or even run TypeScript files.

ohmahjong 5 days ago | parent [-]

I'm not sure what the distinction between "execute" and "run" is; is there a difference?

madeofpalk 4 days ago | parent | next [-]

No, 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.

JoBrad 4 days ago | parent | prev [-]

Node is just inline transpiling the TS into JS, then running the JS.

marcjschmidt 4 days ago | parent [-]

This 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 4 days ago | parent [-]

It's quite close to 100%. It makes one extra-strictness toggle mandatory. Saying it's not TS is much more misleading.