Live data from Hacker News

Ask HN: Is TypeScript worth it?

news.ycombinator.com

121–130 of 469 posts

Re: Ask HN: Is TypeScript worth it?

#121
post #38

Earlier quoted context omitted.

> Did you upgrade Typescript (and if so, why), What an odd question! Even ignoring new features and better type inference that comes with new versions — once you add typescript to your project, it becomes one of its dependencies. Don't you regularly update your dependencies, just as a good practice, not to let your codebase slowly rot?

> Don't you regularly update your dependencies No. Update dependencies as needed for security patches (which typically avoid breaking changes), other than that never update unless there is an explicit business need.

Yeah, I'm with you. I have a lot on my plate, maintaining and developing the main application I work on single-handedly, while also working on several other projects, and putting out fires elsewhere in the company as needed.

I don't have time to spend days to weeks figuring out why upgrading Tailwind to version 3 breaks the project because of (presumably) my version of create-react-app.. do I need to eject, or copy the .ts/.tsx files over to a Vite project? Do i want to fuck around with CRACO, or editing the internal monster of a webpack config file directly?

Yes, critical security updates are important, but you shouldn't just go around upgrading major versions of other packages in your production app, without the understanding that it might be an incredibly time-consuming endeavour.

Re: Ask HN: Is TypeScript worth it?

#122

Earlier quoted context omitted.

Did you upgrade Typescript (and if so, why), or did you upgrade some project dependencies, or type definitions? > No documentation of types means going into source code to see what is there. Sometimes there could be multiple types that could be used for something, and it's not clear which should be used. I haven't had this experience, and I'm not super experienced with Typescript. Are you using VS Code? It typically…

> Did you upgrade Typescript (and if so, why), or did you upgrade some project dependencies, or type definitions? I need to upgrade it because I upgraded a dependency that needed a newer version of TypeScript to compile! And I needed that dependency to be upgraded to use a newer version of NodeJS. It seems that the newer version of TS was more strict, and now I can't find a type from ProtobufJS that fits the code. I…

Did you try regenerating protobufjs and .d.ts files after upgrading?

For me it's something like

    npx pbjs -t static-module -o protos.js *.proto
    npx pbts -o protos.d.ts protos.js

Re: Ask HN: Is TypeScript worth it?

#125
post #120
post #114

#1 – You don't have to upgrade TypeScript versions till you are ready, and newer versions never have breaking changes anyways. The syntax remains strictly compatible with ES6 and beyond. Packages you consume publish compiled JS and aren't dependent on specific TypeScript versions at all. #2 – If libraries haven't published types, just use them as pure JavaScript (which is what you would have done anyways). Lack of do…

Regarding #1: this is not true always. Libraries publish types and their type definitions could use new TypeScript features that could force an update.

> newer versions never have breaking changes anyways.

I've also seen changes to the type system that break existing library typings. (e.g. when they started strongly typing generators.)

I suppose this only happens when you're using the more strict compilation settings, but that's a major draw of typescript in the first place.

Re: Ask HN: Is TypeScript worth it?

#126
post #120
post #114

#1 – You don't have to upgrade TypeScript versions till you are ready, and newer versions never have breaking changes anyways. The syntax remains strictly compatible with ES6 and beyond. Packages you consume publish compiled JS and aren't dependent on specific TypeScript versions at all. #2 – If libraries haven't published types, just use them as pure JavaScript (which is what you would have done anyways). Lack of do…

Regarding #1: this is not true always. Libraries publish types and their type definitions could use new TypeScript features that could force an update.

That's the exact case I was referring to in i) - and what drove me to write this post :)

Re: Ask HN: Is TypeScript worth it?

#128
post #120
post #114

#1 – You don't have to upgrade TypeScript versions till you are ready, and newer versions never have breaking changes anyways. The syntax remains strictly compatible with ES6 and beyond. Packages you consume publish compiled JS and aren't dependent on specific TypeScript versions at all. #2 – If libraries haven't published types, just use them as pure JavaScript (which is what you would have done anyways). Lack of do…

Regarding #1: this is not true always. Libraries publish types and their type definitions could use new TypeScript features that could force an update.

This is rare (I have never run into it in many years of writing TS code and pulling repos from NPM), and if it does happen you can always ignore the definition and turn it back into a plain JS package.

Re: Ask HN: Is TypeScript worth it?

#130
post #23

Earlier quoted context omitted.

Doesn't your counter-argument beg the question whether it is indeed 20% BS vs. 80% value? I think the OP is asking about pretty much that percentage. Personally I feel it's more like 70% BS vs. 30% value. Types, after all, are a very weak ontology, i.e., you still cannot know for sure that just because your code compiles it interprets the values it's getting from other party's code correctly. I would even argue that…

Come on, the OP literally said: > I want to skip over the static typing benefits argument, because I think it is well understood that static typing is a good thing The OP is interesting in talking about how much of a pain in the ass TS tooling is, and... it's fair to say it's annoying. If you accept that static types are good (and the OP explicitly said they do ), then what are going to do? Basically the OP is saying…

Let me clarify - I pretty much agree with what the parent says - "it's more like 70% BS vs. 30% value".

I do still want that value i.e. static typing, but as you point out I can't get that without the BS. And so I would rather have no typing which is the only other option (except using a different language).

Post reply on HN