Live data from Hacker News

Node.js adds experimental support for TypeScript

github.com

201–210 of 570 posts

Re: Node.js adds experimental support for TypeScript

#201
post #47
post #39

Earlier quoted context omitted.

> In Python, I've even heard of people writing types in source code but never checking them This is my main approach. Type hints are wonderful for keeping code legible/sane without going into full static type enforcement which can become cumbersome for rapid development.

You can configure typescript to make typing optional. With that option set, you can literally rename .js files to .ts and everything "compiles" and just works. Adding this feature to nodejs means you don't even have to set up tsc if you don't want to. But if I were putting in type hints like this, I'd still definitely want them to be statically checked. Its better to have no types at all than wrong types.

Or you can configure the TS compiler to allow JS imports, then everything also compiles and works, but you can slowly convert your codebase from JS to TS file by file and be sure that all TS files are properly typed and all JS files are untyped instead of having everything as TS files where some are typed and some are not.

Re: Node.js adds experimental support for TypeScript

#202
post #63
post #36

Earlier quoted context omitted.

I would rather let Typescript evolve a few more years before freezing its development via standardization

I'm interested to know what are some things that you (or anyone reading this) feels that Typescript is missing / should change?

I don't have a list and I don't even write TS (or do much web dev in general), but I do follow their announcements and it seems every one of them brings new big type things.

Nevertheless, I don't see TS support in e.g. browsers being anything useful, as in practice all JS code deployed is already packaged somehow, so the stage to convert TS to JS (and then also checking the types..) fits that just fine. It's useful for hobbyists, but I don't that is a reason enough to come up with a standard.

Re: Node.js adds experimental support for TypeScript

#203

Earlier quoted context omitted.

its about time google chrome started making a typescript engine maybe? and get rid of JS in phases?

This is a persistent meme that has no basis in reality. A TypeScript engine is a JavaScript engine, since everything that can be done in JS can be done in TS. It's plausible, maybe, that there could be some additional optimisations on TS code where the engine is sufficiently happy with all types in a subset of the program. But that would be on top of all existing JS engine features, unless you want your engine's perf…

That's a pretty obtuse interpretation of the comment. Browsers natively being able to run Typescript code / .ts files instead of requiring transpiling to plain Javascript would be a large boon to the TS ecosystem by making basically everything easier. Even if it's just stripping the TS and running the plain JS it would already be helpful, but it running the typechecking beforehand would be wonderful.

Re: Node.js adds experimental support for TypeScript

#204
post #42
post #23

Earlier quoted context omitted.

There are a few optimizations that types can use but 99% of applications wouldn't benefit from them anyways.

Taking one link out of the toolchain (tsc) would already be a huge blessing. And naive me hopes for a future where in my web-app I can set a policy that any non-ts, type-incompliant code is not allowed to run. The amount of exceptions I get in the console from terrible garbage-code outside of my control but that I have to include because enterprise is staggering. Would love to have a meta-setting which would just kil…

Why is taking out the part that actually checks the types at the developer's side a huge blessing?

Or if you are hoping to get the benefit of type checking in the browser itself (taking the same sweet time as tsc, but this time on every browser instead of once in the CI), then how long would you want to wait to be able to actually use the new typing functionality described in e.g. the latest TS annoucement? https://devblogs.microsoft.com/typescript/announcing-typescr... .

Because it would take a while until that would then become the standard and then become available in every browser. And you still need to provide the JS versions, because not every browser is going to support TS.

In the meanwhile you could just keep using tsc just as before and get access to new functionality immediately.

(I imagine you could run tsc in the browser right now if you really wanted to.)

Re: Node.js adds experimental support for TypeScript

#205
post #4

My favorite deno feature is coming to node directly. Awesome! Maybe this means I don't always have to install esbuild to strip types - very excited how this will make writing scripts in TypeScript that much easier to use. I lately have been prefering Python for one off scripts, but I do think personally TypeScript > Python wrt types. And larger scripts really benefit from types especially when looking at them again a…

Have you tried https://github.com/google/zx?

Re: Node.js adds experimental support for TypeScript

#206
A long time ago I started converted to using node js for backend work, seemed to offer many benefits over writing code in PHP without bringing many problems of Java. I found node to be somewhat clunky and a language where you had to bolt it together to get the language you wanted. Eventually started writing golang and it felt much easier to write, sometimes way more verbose but the type safety just made coding simpler.

Typescript seemed like a good option but was just another bolt on, I am not sure what value you gain by using Typescript over Golang, you have nice defined types which is great but it does not solve other issues with the language that are resolved in golang (also solved in deno).

One large benefit of using node over golang is the speed of prototyping something which I think having to use type script largely negates, so I can not really decide if this is a good step forwards or is making node loose some qualities that made it a good choice in other ways.

Re: Node.js adds experimental support for TypeScript

#207

Earlier quoted context omitted.

https://www.typescriptlang.org/docs/handbook/2/types-from-ty... https://www.typescriptlang.org/docs/handbook/2/template-lite... alone puts TS over anything that Java has.

> alone puts TS over anything that Java has. Virtual Threads alone challenge this assumption. Syntax bloat is not a feature.

[deleted]

Re: Node.js adds experimental support for TypeScript

#209

A long time ago I started converted to using node js for backend work, seemed to offer many benefits over writing code in PHP without bringing many problems of Java. I found node to be somewhat clunky and a language where you had to bolt it together to get the language you wanted. Eventually started writing golang and it felt much easier to write, sometimes way more verbose but the type safety just made coding simple…

I guess if you already know Javascript, or have inhouse experience vs. learning Go. We use it with cdktf as previous fe experience, seemed logical vs. Go

Re: Node.js adds experimental support for TypeScript

#210

A long time ago I started converted to using node js for backend work, seemed to offer many benefits over writing code in PHP without bringing many problems of Java. I found node to be somewhat clunky and a language where you had to bolt it together to get the language you wanted. Eventually started writing golang and it felt much easier to write, sometimes way more verbose but the type safety just made coding simple…

I mean the obvious answer is language familiarity, If your projects frontend code is in javascript/typescript ( which it is ), then using node is an easy choice. Shared libraries, shared types, etc etc
Post reply on HN