Node.js is able to execute TypeScript files without additional configuration
31–40 of 275 posts
Re: Node.js is able to execute TypeScript files without additional configuration
#32Re: Node.js is able to execute TypeScript files without additional configuration
#33It looks like this works by stripping away the type information, so at best it saves you a transpilation pass and doesn't improve safety.
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.
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.
Re: Node.js is able to execute TypeScript files without additional configuration
#34It looks like this works by stripping away the type information, so at best it saves you a transpilation pass and doesn't improve safety.
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.
that's exactly the point--GP is pointing out that node can't do that part
Re: Node.js is able to execute TypeScript files without additional configuration
#35Earlier quoted context omitted.
One of Typescript's design goals is that removing all type-related parts of the source text should yield a valid JavaScript file. A typescript compiler does not generate code (unlike, say, PureScript). You can run a typechecker (such as tsc) that check various properties of your code statically, relying on the type information. It is then erased. The same applies, say, to Python: type annotations are ignored at runti…
> A typescript compiler does not generate code Except for where it does: Enums, namespaces, parameter properties, etc.
Re: Node.js is able to execute TypeScript files without additional configuration
#36Re: Node.js is able to execute TypeScript files without additional configuration
#37Earlier quoted context omitted.
One of Typescript's design goals is that removing all type-related parts of the source text should yield a valid JavaScript file. A typescript compiler does not generate code (unlike, say, PureScript). You can run a typechecker (such as tsc) that check various properties of your code statically, relying on the type information. It is then erased. The same applies, say, to Python: type annotations are ignored at runti…
> A typescript compiler does not generate code Except for where it does: Enums, namespaces, parameter properties, etc.
I don't think those features are ever going to go away, because they've been around for so long and are so widely used. But I generally use erasableSyntaxOnly in new projects, because I find it's useful when my typescript source matches the generated Javascript code as much as possible.
Re: Node.js is able to execute TypeScript files without additional configuration
#38Bun can do it for years now. I think it's time to move on.
Re: Node.js is able to execute TypeScript files without additional configuration
#39Earlier quoted context omitted.
This has nothing to do with the "node world". Such an enormous feature would have to go into ECMAScript. Which is very, very unlikely to ever happen, they may as well design a new language. All those runtimes implement that spec. Expecting them to write an extremely complex new feature that is easily more complicated than everything already implemented (especially with backwards compatibility, and given that the lang…
Can't be too hard imo. Primitives can contain an extra metadata field for the types defined in the code. This doesn't really interfere with the runtime and will be backwards compatible. The runtime of course still doesn't actually have to do any type checking, it's just forwarding the type information on a new metadata field so it's not in any way interrupting the core flow of the runtime logic. As a result you can s…