Live data from Hacker News

Ask HN: Is TypeScript worth it?

news.ycombinator.com

181–190 of 469 posts

Re: Ask HN: Is TypeScript worth it?

#181
post #165

> Is Typescript worth it? > I want to skip over the static typing benefits argument… Typescript, as the name implies, adds types to your script. If you don’t see the benefits of types then typescript may not be for you. > My issue is with the amount of extra work it places on developers… and doesn't deliver all that much value. If you think adding types doesn't add much value then typescript may not be for you. In my…

> If you don’t see the benefits of types then typescript may not be for you. At this point in my 20+ year career working with mostly dynamic languages, my feeling is that if you don't see the benefits of types, then programming isn't for you.

I would narrow this slightly to "programming with other people". For instance, I love Python for small personal projects and interview questions and stuff like that, but I've found working with it professionally to be much more of a headache.

Re: Ask HN: Is TypeScript worth it?

#182

As i said before, a lot of people expect that writing typescript is as easy as writing js, which is not. I estimate the typescript tax to be around 40-100% more time, especially if you want to do typescript right and not use `any` all over the place. And besides, typescript is a poor fit for someone who is used to writing highly dynamic, lambda based code, which is one of the main niceities of js. My guess is that a…

These estimations are pure imagination. I doubt you have `any` real data to support it. Also, that is not the reason why Typescript was created, nor the reason why people adopt it, not even what Typescript really is. Today, almost every Node.js framework supports Typescript out of the box. I challenge you to provide a modern framework that doesn't provide types. And this is not an opinion, nor it is wishful thinking,…

An estimation doesn't need data. It's a best guess. I don't think its fair to call it an imagination. As far as we know that's what he thinks based off his observations.

Re: Ask HN: Is TypeScript worth it?

#184
In my experience yes, to the extent that I don't intend to write vanilla JS ever again if I can possibly help it. If you've done webdev professionally in the past 5+ years you've almost certainly already been transpiling so to draw the line at introducing something as massively useful as static typing seems both arbitrary and bizarre.

FWIW I can't recall the last time I reached for a 3rd-party library and found that it was lacking types. The DefinitelyTyped project has really done a remarkable job expanding type coverage. And even in that rare case where you might need to add type definitions yourself it's simple enough to do so.

There's a ton of room for improvement around error messages, no argument there. The TS team is very much aware of this and they're working on it but it'll take time.

Re: Ask HN: Is TypeScript worth it?

#185
Are tests useful? Because this is what TypeScript gives you: it helps you avoid regressions.

If I change a signature, tests fail. If I pass junk data, tests fail. It's like invisible live tests and people forget this.

As in the other recent discussion, yeah, you can live without tests and you can live in JS-land. Whether it's worth it it depends on you. TS and traditional testing lets me ship updates without even opening node or the browser.

Re: Ask HN: Is TypeScript worth it?

#186

One of the biggest mistakes that I see devs making is caring too much about making TypeScript happy when they know it doesn't really matter. There are a lot of cases where it's totally reasonable/rational and honestly fairly safe to just throw in a well-scoped "any" cast, a `// @ts-expect-error` comment, etc. If you know what you're trying to do, and TS isn't understanding, sometimes it's just a lot more expedient to…

This feels like telling Haskell developers that they should use unsafePerformIO and unsafeCoerce more.

It's much more like reminding TS developers that Go developers have to use `interface{}` all the time, because some types are actually hard for compilers/typecheckers to deal with.

Re: Ask HN: Is TypeScript worth it?

#188

I'm old enough to have worked on two different large enterprise applications which predated TypeScript and it was a nightmare. Personally I've found that JavaScript lends better to a functional style of coding but there are no protections in the language to enforce this and both codebases I saw had a weird mismatched set of object oriented and functional style principals. Defined classes, prototypical inheritance, mo…

I worked many years before TS too and happened to have been working on very neat codebases back then, though I did have the luck of working with a really talented set of people. I conceed that perhaps you are correct about this - it does force people to write less strange code. JS gives you so much freedom that if you don't keep it simple you can really hang yourself. However if you put care into your code and keep i…

IMO TypeScript nudges you away from bad patterns. If it’s a mess to type it, it’s probably a mess in general.

If you are in a very rare situation and think you know better then there’s “any”, although at that point you really need to think “I’m risking runtime errors and this code is confusing, is it worth it or is there another way?”

Re: Ask HN: Is TypeScript worth it?

#189

Hi there! I work on the TypeScript team and I respect your feedback. Of course I do think TypeScript is worth it, and I'll try to address some of the points you've raised with my thoughts. i. Dependency management is indeed frustrating. TypeScript doesn't create a new major version for every more-advanced check. In cases where inference might improve or new analyses are added, we run the risk of affecting existing bu…

Thanks for responding, and thanks for your work for the community! I sometimes place myself in the shoes of devs building TypeScript, especially when I am a little frustrated, and most of the time I realize that a lot of these issues are incredibly hard to solve. > i. Dependency management is indeed frustrating. TypeScript doesn't create a new major version for every more-advanced check. In cases where inference migh…

Re libraries incompatible with certain typescript versions - e.g. protobufjs fix - it’s been my experience that you want to try and only use compilers specific to each library and compile libraries separately. It’s unfortunate but the JS community often tries to run all JS for a project through the same single compiler tool chain, using one global version of the compiler instead of relying on and effectively linking the JS output for each library. Unless you routinely rewrite third-party libraries to match your toolchain’s expectations, you’re going to have a hard time doing that.

For a library that generates code, that’s a special case, as the code it generates must target a particular language version. You have three choices: 1. Upstream a fix as you propose; 2. Side-by-side install both TS 4.6 and TS 4.7 using workspaces or sub-projects and have some of your code compile with 4.6 and then link the results or 3. Find a replacement that is updated to 4.7. For example, https://github.com/stephenh/ts-proto has 4.7 support listed in its readme.

Re: Ask HN: Is TypeScript worth it?

#190

I get your point, but it actually increases my productivity. Some examples: I no longer have to worry about things unknowingly becoming undefined or falsey. When chaining map, filter, and reduce, I know at every step of the way what kind of object I’m working with. And when I use a dependency, I don’t have to trust possibly outdated documentation but can rely on types. Just these three things make it 100% worth it fo…

"Thank you, TypeScript." "Thank you, JavaScript." < something I have said sarcastically on many occasions.
Post reply on HN