← Back to context

Comment by gleenn

4 hours ago

Clojurescript not ClojureJs, and Typescript doesn't run in the browser, it has the exact same issues/limitations: it must be compiled to JavaScript first.

Except TS has much wider community support. The type definitions/wrappers are already written.

Compiling TypeScript is just stripping out types

  • Isn't that like saying the Internet is only written in English if you strip out all the non-English. All C-style languages are fully cross compatible if you only use semicolons.

    I can't write Typescript into a browser without cross-compilation and "stripping out types" involves parsing and manipulating code. That's a different language.

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

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

      1 reply →

    • 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

      2 replies →