Live data from Hacker News

Ask HN: Is TypeScript worth it?

news.ycombinator.com

51–60 of 469 posts

Re: Ask HN: Is TypeScript worth it?

#51
post #50

Yep. I've had the foolish (mis?)fortune of scaling a couple of frontend projects from small to not-so-small starting in JavaScript and then converting to TypeScript. In each one, starting out with vanilla JavaScript was faster (no build!), but at some point our velocity would slow as changes required more testing infrastructure. After switching to TypeScript, we were faster than before. Sure, dealing with TypeScript…

100% my experience too. It's not that much more work to get TS setup for a projects and the dividends for doing so are vast in the long run.

Re: Ask HN: Is TypeScript worth it?

#52
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.

I am the opposite. To me, dependencies in a project are a debt to which I regularly make my payments by keeping them up-to-date and resolving breaking changes as they arise. Allowing dependencies to fall too far out of date, in my experience, made updates — when they became necessary — too painful.

Re: Ask HN: Is TypeScript worth it?

#53

After years of Flow, Typescript, Webpack, React, JSX, etc, I went back to just vanilla HTML, CSS, JS for my most recent production project ( https://play.d2lang.com , which is open source). The experience was great. I didn't find myself missing any of those tools.

Just curious - how many developers worked on that project, and for how long?

Re: Ask HN: Is TypeScript worth it?

#54

My use case is a bit odd, but I've been using it for small personal web projects — so small that no dependencies are being pulled in and bare tsc is being used in place of a bundler — and as someone who doesn't have all of the ins/outs and do's/don'ts of JavaScript committed to memory (the vast majority of code I write is Swift or Kotlin) it's wonderful to have something catching errors before I save and reload the b…

Although this seems to be the opposite sentiment to what many are saying which is that it's more useful in larger projects, with many contributors, I think I probably understand this side more.

Dependencies are where it starts to get tricky. It also gets tough when someone else has configured TypeScript, or you need to add some complex config. I would still opt out for smaller projects because they don't quite benefit so much from TypeScript, and eventually I would expect to run into something that would eat at hours of my time for a simple change.

Re: Ask HN: Is TypeScript worth it?

#55
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 for me.

Re: Ask HN: Is TypeScript worth it?

#58
post #50

Yep. I've had the foolish (mis?)fortune of scaling a couple of frontend projects from small to not-so-small starting in JavaScript and then converting to TypeScript. In each one, starting out with vanilla JavaScript was faster (no build!), but at some point our velocity would slow as changes required more testing infrastructure. After switching to TypeScript, we were faster than before. Sure, dealing with TypeScript…

> Sure, dealing with TypeScript can be a hassle, but it is less hassle than dealing with broken software.

Can you think of examples where it's prevented broken software? I would prefer to spend more time writing good unit test coverage which in my experience would catch anything that TypeScript would have caught. I have seen it be more useful for autocomplete and self-documenting code, which I could get using JSDoc or something similar.

Re: Ask HN: Is TypeScript worth it?

#59
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 lot of people with a background in java and c# found themselves writing server side js and were really unconfortable with this paradigm, so they tried again to turn js into what they knew best - an imperative object oriented programming language. Now, i'm not saying that types are a bad thing, i for one like typescript especially in projects with a lot of people, but, it's funny to see new people struggling to finish a task that should take a few hours in days.

Re: Ask HN: Is TypeScript worth it?

#60
I like using Typescript in general, but sometimes it becomes painfully obvious that it's Javascript with type checking added to it at a later time. So I actually kind of which there was a language I could use instead which is typed from the ground up and requires less boilerplate, no painful syntax and provides more extensive type checking. But of course the major downside would be that it becomes hard to mix that with plain Javascript.. Also due to its popularity I think this is the least of all evils.
Post reply on HN