Live data from Hacker News

Ask HN: Is TypeScript worth it?

news.ycombinator.com

271–280 of 469 posts

Re: Ask HN: Is TypeScript worth it?

#273

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…

> Actually I think documentation is almost universally bad, I don't think Go or other languages are that much better (I don't want to wade into that debate though). The thing is, having TypeScript means you need more documentation. Even some pretty well documented JS/TS libraries completely neglect TypeScript and the end effect is that you end up having to guess things, or start reading source code. I don't actually know how you could improve this situation.

I think Rust approach is the best one so far, every package published in crates.io has an entry in docs.rs (that is created automatically when you publish your crate in crates.io), so I think Microsoft could improve it for every package published to create an entry in a domain specifically for js docs, if a project does not have it will look empty, but slowly the devs will start adopting it at the point that major libraries will improve the docs compared to what we have today.

Re: Ask HN: Is TypeScript worth it?

#274
post #254

Earlier quoted context omitted.

TS#### error messages was a brilliant idea to make them more ~googleable~ bingable at least.

Isn't that pretty standard for compiler error messages? The C# compiler uses CS\d{4} for example. MSVC, MSBuild, various other build tools (at least on the Microsoft side) all use similar patterns with different prefixes. That being said, it seems like Clang or GCC don't do that at all, which perplexes me a bit. Perhaps it doesn't matter much when error messages are never localized.

I guess TypeScript and C# having Anders Hejlsberg in common probably helps with things like that?

Re: Ask HN: Is TypeScript worth it?

#275

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…

Offtopic perhaps, but if most of your code is in Swift or Kotlin, have you tried the new Kotlin frontend support? I don't have any project where I can use Kotlin in the backend right now but I've always wanted to give the Kotlin frontend a go as an alternative to TypeScript.

Re: Ask HN: Is TypeScript worth it?

#277

Typescript is great but be aware that sometimes it can annoyingly slow you down. Consider these scenarios: - You want to use a third party library but it is completely untyped - You need an object but you're just prototyping it. You don't yet know which keys will be optional - You type a key of one of your objects. Now you load or fetch data from an API and want to assign that to it. But typescript complains because…

If you don't know what parameters are optional, just add the little question mark to every variable and remove the ones that turn out mandatory? Better to have some type info than nothing at all.

If you fetch data and TS tells you the result may be undefined then I guarantee you your code would've randomly crashed at some point in the future because of it. That error is a feature, not a bug!

Re: Ask HN: Is TypeScript worth it?

#278

Earlier quoted context omitted.

Typescript doesn’t just statically type. That’s easy. It does program flow analysis to 1) infer type and 2) ensure the inferred types actually work. I think in most statically type environments, the type analysis engine relies a lot of on the developer to define the correct types in the correct places, but the types in TS are always _logically_ correct. As in absolutely correct (unless of course you eject from the ty…

> but the types in TS are always _logically_ correct. As in absolutely correct Erm... type Test = Array ; const xs: Test = []; const x = xs[0]; What's the type of x, according to typescript's default behavior? It's number [0]. What's the logically correct type? Some sort of a Maybe , which typescript doesn't have; so a number|undefined instead. Most people don't use typescript at that level of soundness, both because…

there is --no-unchecked-indexed-access option for it. Which is not on by default or in --stric mode because indeed in practise it's painfull

https://devblogs.microsoft.com/typescript/announcing-typescr...

Re: Ask HN: Is TypeScript worth it?

#279

Earlier quoted context omitted.

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).

> And so I would rather have no typing which is the only other option (except using a different language).

This part is what is so wild to me. I simply cannot imagine throwing the baby out with the bathwater, so to speak, to throw out the entirety of static typing just because of the BS around it. In my experience, static typing is superlative, it would have to be some extremely rare situation for me to give it up.

Re: Ask HN: Is TypeScript worth it?

#280

Earlier quoted context omitted.

Thanks for your work, TS saves me time every day. I was saying something similar to the op 3-4 years ago but really cannot picture working without some kind of type safety in JS now.

> TS saves me time every day. Hmm, not my experience. I do TS for years now and still today I'm spending more time on fighting/pleasing TS compared to the actual code. JS with all its node_modules dependencies is a complete nightmare to get the typing right. I regularly have to change good solid code to please TS, but at the same time TS often doesn't complain when the typing is obviously wrong. I once started with A…

You know you can just use transpileOnly option and ignore some errors? I use it like that and it’s helpful to model data and speeds up development.
Post reply on HN