Live data from Hacker News

Node.js adds experimental support for TypeScript

github.com

131–140 of 570 posts

Re: Node.js adds experimental support for TypeScript

#131
post #34

If Node.js can run TypeScript files directly, then the TypeScript compiler won't need to strip types and convert to JavaScript - it could be used solely as a type checker. This would be similar to the situation in Python, where type checkers check types and leave them intact, and the Python interpreter just ignores them. It's interesting, though, that this approach in Python has led to several (4?) different popular…

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.

Re: Node.js adds experimental support for TypeScript

#132

It would be nice for debugging if at least simple npms could just bundle their .ts files without any processing, so we could see the comments and types as they existed in the git repo. Apps can always minify them later. (I use Deno, but also use some npms.)

You can simply create npm packages which contain only the 'unprocessed' TS source files (or really any type of files - for instance I experimented with using npm as package for C/C++ projects in the past, it works just fine). Pre-bundling or compiling from TS to JS is just a convention. And in case of bundling not a good one IMHO, because bundling should only be a final step in the top-level project. One good reason to compile the package content to .js/.d.js/.map files is that the resulting package is usable both in JS and TS projects.

Re: Node.js adds experimental support for TypeScript

#133

I have mixed feelings about this. While I do use TS with Node.js today and absolutely like the concept, its type system is still far from something mature and stable like C#. We keep running into ceilings (EDIT: lack of completeness/depth, not lack of complexity) all the time, and TypeScript questions on Stack Overflow is basically a library of workarounds. Mostly bad ones. So if I worked on Node.js I would prefer it…

This is the first time I'm hearing such a claim. In C# you can't work with optional generics because an optional reference type is different from an optional value type. C#s poor type-inference often requires you to type out types thrice. You can't declare constants or class members with type-inferrence. The only way to define sum-types (A | B | C) is through intefaces and I'm pretty sure they can't be sealed. Defini…

Sorry I probably used the wrong term, not a native English speaker. I didn't mean lack of complexity or lack of "features" but rather the lack of carefully thought-through feature "depth". Like, we can infer generic arguments which is nice, but then we try doing that with some keyof complex type and it doesn't work. And later we find an issue on GitHub saying that it's not implemented. Which is fine, I love TS anyway and it's evolving.

Re: Node.js adds experimental support for TypeScript

#134

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…

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

[dead]

Re: Node.js adds experimental support for TypeScript

#135
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]

https://github.com/tc39/proposal-type-annotations?tab=readme...

You’re welcome.

Re: Node.js adds experimental support for TypeScript

#136
post #119
post #111

Earlier quoted context omitted.

1. *Type Inference*: TypeScript can automatically infer types from context, reducing the need for explicit type declarations. 2. *Union and Intersection Types*: Allows combining multiple types, offering more flexibility in defining data structures. 3. *Literal Types*: TypeScript supports exact values as types (e.g., specific strings or numbers), which can be useful for more precise type-checking. 4. *Type Aliases*: Y…

That's just an copy-paste of some features, not a comparison with Java which does most of that too.

[dead]

Re: Node.js adds experimental support for TypeScript

#137
post #46

Earlier quoted context omitted.

Yeah, my personal experience is that easily 95% of devs I work with/have met in person, if not closer to 99%, prefer statically typed languages. Maybe that’s a biased sample, but I do think the overall preference among devs is very strong. I also see JS slowly, more-or-less becoming TypeScript over time.

Let's make it 94 then. I think typescript is an abomination forced by java developers that don't want to learn javascript.

Guard rails on a bridge are an abomination forced onto us by government because people don’t want to learn how to fly.

Re: Node.js adds experimental support for TypeScript

#138
post #6

support for typescript as long as you are only using it for type checking, not if you are also using features that are not supported in the javascript version you are targeting.

> not if you are also using features that are not supported in the javascript version you are targeting. reply

This is only 'half-assed' anyway, TS will only emulate new language features on older JS target version, but not any Javascript runtime features (like new Object methods). For the latter you will still need a separate polyfill solution.

Re: Node.js adds experimental support for TypeScript

#139

I have mixed feelings about this. While I do use TS with Node.js today and absolutely like the concept, its type system is still far from something mature and stable like C#. We keep running into ceilings (EDIT: lack of completeness/depth, not lack of complexity) all the time, and TypeScript questions on Stack Overflow is basically a library of workarounds. Mostly bad ones. So if I worked on Node.js I would prefer it…

This is the first time I'm hearing such a claim. In C# you can't work with optional generics because an optional reference type is different from an optional value type. C#s poor type-inference often requires you to type out types thrice. You can't declare constants or class members with type-inferrence. The only way to define sum-types (A | B | C) is through intefaces and I'm pretty sure they can't be sealed. Defini…

C# has record (product) types now.

Re: Node.js adds experimental support for TypeScript

#140

Earlier quoted context omitted.

What's an example of a ceiling? Out of all the mass-market programming languages, TS arguably has the most advanced type system in the world. It's a modern marvel that they got it working on top of Javascript.

I think it took the seemingly impossible challenge of bringing typing to a dynamic language that made typescript so powerful in the first place. All other static languages start bottom up, simple to more complex, but end up getting boxed in by their own design. TypeScript started top down, trying to map itself on to a fully dynamic language. Never getting boxed in, just trying to 'fill' the box that is all the possib…

Typescript isn't particularly powerful compared to other non-mainstream languages, though, which is why the parent comment was careful to add that caveat. Which is to say that I'm not sure the idea that "all other static languages" start simple and get boxed in stands up.

You may have a point that Typescript would have been relegated to obscurity with all the others had it tried to start "top down" as a brand new language. There may be some truth that it is a necessity of a language to start simple in order to become accepted in the mainstream and that Typescript only made it because it rode on the coattails of a language that also started simple: Javascript.

Post reply on HN