Live data from Hacker News

Node.js adds experimental support for TypeScript

github.com

151–160 of 570 posts

Re: Node.js adds experimental support for TypeScript

#151

Earlier quoted context omitted.

There is an EcmaScript proposal to go in that direction: https://github.com/tc39/proposal-type-annotations I think this should be part of the language spec.

Beyond ugly. They should just make TS official and be done with it. E: I thought it was JSDoc proposal. Ignore the comment.

There is no language spec for TS. No alternative implementations. All we have is checker.ts. It's ugly and slow.

Re: Node.js adds experimental support for TypeScript

#152

Bun’s DX is pretty unprecedented in this space, and most of my use cases are now covered / not causing Bun to crash (when actually using run-scripts with `bun run`). Meanwhile, I can’t configure node to not require extensions on import, nor have tsc configured to automatically add .js extensions to its compiled output, without adding on a bundler… although native TypeScript support would remedy this nit quite a bit,…

> unprecedented

Well except for Deno...

Re: Node.js adds experimental support for TypeScript

#153

Earlier quoted context omitted.

There is an EcmaScript proposal to go in that direction: https://github.com/tc39/proposal-type-annotations I think this should be part of the language spec.

Beyond ugly. They should just make TS official and be done with it. E: I thought it was JSDoc proposal. Ignore the comment.

I did only briefly look at the proposal. What did you find so ugly?

Re: Node.js adds experimental support for TypeScript

#154
post #146
post #99

Earlier quoted context omitted.

> we all just wanted java with JIT, more feature rich type system Java has JIT. How is TypeSript type system feature-richer than the Java one?

I don't use them directly much, but template literal generic and contidiontal types is probably the closest a mainstream language has inched towards dependent types. Some examples of TypeScript power: - SQL database in TypeScript types: https://github.com/codemix/ts-sql - Statically typed raw SQL queries: https://github.com/andywer/squid?tab=readme-ov-file#tag-func... - (Someone fill in your TS hackery for me)

There are various programming language interpreters that run entirely in the type system:

- BF: https://github.com/susisu/typefuck

- Assembly: https://github.com/judehunter/ts-asm

Re: Node.js adds experimental support for TypeScript

#155
post #28

I'm honestly giddy. This could be the (slow) beginning of a new era, where "JS with types" is finally a native thing. I'm even willing to forgive all the mess that CJS vs. ESM is if they manage to pull this off. I hope this sees widespread adoption/usage, which might finally cause some movement to integrate TS into ecmascript after all. Some dynamically-typed language fanatics (which are, in my opinion, completely de…

> the reality that static types are what the vast majority of devs want [citation needed]

The reaction emoji on the merged PR are not particularly ambiguous.

Re: Node.js adds experimental support for TypeScript

#156

One thing to note is that it is impossible to strip types from TypeScript without a grammar of TypeScript. Stripping types is not a token-level operation, and the TypeScript grammar is changing all the time. Consider for example: `foo ( x )`. In TypeScript 1.5 this parsed as (foo (x)) because bar&baz wasn’t a valid type expression yet. When the type intersection operator was added, the parse changed to foo (x) which…

It's possible that internal SWC version will be versioned alongside Node, meaning TS syntax support won't drift. Or am I missing something?

Re: Node.js adds experimental support for TypeScript

#157

Earlier quoted context omitted.

The recently-added test runner is very cool too!

YES. It was such a joy to be able to ditch Jest completely and run tests natively.

i tried that but had to revert to vitest, the native test runner feels incomplete atm.

Re: Node.js adds experimental support for TypeScript

#158

One thing to note is that it is impossible to strip types from TypeScript without a grammar of TypeScript. Stripping types is not a token-level operation, and the TypeScript grammar is changing all the time. Consider for example: `foo ( x )`. In TypeScript 1.5 this parsed as (foo (x)) because bar&baz wasn’t a valid type expression yet. When the type intersection operator was added, the parse changed to foo (x) which…

You would also have to update your compiler. I guess you could phrase this as: you can't update your TS versions independently from your node.js version. But that's probably not an issue.

Re: Node.js adds experimental support for TypeScript

#159

Earlier quoted context omitted.

Typescript is way better than Java, in my experience. It's a lot less verbose. A lot more flexible.

They are not comparable. If anything, Kotlin is the equivalent in the JVM universe.

Kotlin is much closer to Java than to TypeScript even in terms of flexibility.

Re: Node.js adds experimental support for TypeScript

#160
post #99

I really enjoy typescript and have been yearning for a typescript runtime but I can't help but laugh that I left java all those years ago to finally seek something a lot closer to java. I guess we all just wanted java with JIT, more feature rich type system and gradual typing. Also for all the shortcomings of npm ecosystem, it is a lot less daunting and more fun to be using libraries in this ecosystem. And surprising…

> we all just wanted java with JIT, more feature rich type system Java has JIT. How is TypeSript type system feature-richer than the Java one?

Java and Typescript have fundamentally different type systems, that lead to drastically different ways to approach types.

Utility types, like Partial, are basically impossible to represent in Java except with almost-duplicated classes.

Post reply on HN