logoalt Hacker News

Stratoscopeyesterday at 7:38 PM3 repliesview on HN

That is true only if you confine your TS code to be pure JS plus type annotations.

There are TS constructs that require compilation into equivalent JS, such as enums and namespaces.


Replies

hermanradtkeyesterday at 7:58 PM

Are there any other?

Namespaces are heavily discouraged. Some teams still use enigma but most people in the know us unions of strings.

I know the TS team regrets enums and I have not seen any plans for adding additional keywords that break type stripping.

show 1 reply
p_lyesterday at 8:16 PM

"fortunately" we can load swc compiled to wasm to deal with that.

iglyesterday at 8:16 PM

absolutely nobody used those outside of a language demo. We also got --erasableSyntaxOnly last year to remove them from the language. The TS team considers them “mistakes“ for a really long time now

show 1 reply