by pier25 · 2y ago · 0 comments
Edit:
The docs mention:
> Because Bun can directly execute TypeScript, you may not need to transpile your TypeScript to run in production. Bun internally transpiles every file it executes (both .js and .ts), so the additional overhead of directly executing your .ts/.tsx source files is negligible.
https://bun.sh/docs/runtime/typescript
The idea I'm getting from this is that both JS and TS are transpiled to something else. Are types preserved in this bytecode, AST, or whatever it is?
At this point, IMO, it should just be implemented within V8. Would make things much simpler for everyone.
There is a TC39 proposal for that: https://github.com/tc39/proposal-type-annotations
But on the other hand, it would be already fantastic to have at least a subset of TypeScript...
--
Why incur the type-declaration overhead if they are not used after all?
This is the only way to execute TypeScript. That's how every tool that "executes" TypeScript works.
There is a persistent fantastical hope that TS can somehow be a compiled language. It can't, not without breaking compatibility with JS. Until, of course, someone manages to compile JS - but at that point TS would be irrelevant.
I say this as someone who loves TS and wouldn't want to be without it: TS is a fancy linter. JS defines the execution semantics of the language.