Remix.run Logo
hootz 6 hours ago

That is type stripping and is incompatible with syntax that requires transpilation, so it is not native TypeScript support.

jazzypants 6 hours ago | parent | next [-]

TypeScript is a wide umbrella. For instance, Experimental Decorators are shunned by many (including me), but they are still used by millions. If I don't use any syntax that requires transpilation, am I not still using TypeScript?

Now that we have `satisfies` and `as const`, there's really no reason to ever use an enum. In my opinion, TypeScript is best when it is simply used as Language Server, and it should never have had runtime implications in the first place.

alanning 6 hours ago | parent | prev | next [-]

Node v22.7.0 added support for TypeScript syntax that requires transformation:

`node --experimental-transform-types example.ts`

As for whether this matches your definition of "native support" or not...

Source: https://nodejs.org/en/blog/release/v22.7.0

ifwinterco 6 hours ago | parent | prev | next [-]

Isn't that mostly just enums?

Is there anything else that doesn't run as valid JS if you strip the types (and maybe some other extra keywords)out?

Genuine question, in my head there's not much, but TS has a few weird corners I maybe haven't used

silverwind 5 hours ago | parent | next [-]

https://www.typescriptlang.org/tsconfig/#erasableSyntaxOnly covers them all, I strongly recommend running with that option enabled to be future-proof.

n_e 5 hours ago | parent | prev [-]

enums and decorators mainly. There are also subtleties such as having the ts file extension in imports. Also imports aren't transpiled in cjs so you need to need es modules.

I'm using it in my projects with no issues.

silverwind 5 hours ago | parent | prev [-]

Modern Typescript does not need runtime features.

moritzwarhier 3 hours ago | parent [-]

Your comment might lack explanation, but indeed the TS team has mentioned multiple times that they don't want to add any more features that require transpilation (as opposed to "dumb" type stripping and being a strict superset of JS).

IIRC they "almost" recommend against using them (the last part, I haven't researched again now).

But the usage of many features has reached a sort of point of no return, so I hope Node will go the route of making the experimental transpilation the default for TS files at some point.

Goes to show how strong the appeal of syntax is, especially enums.

To people coming from languages with enum support, it just looks so much more organized to use them, compared to union types, despite all of the (many) drawbacks.