News for hackers. Stuff that matters.
Re:TypeScript 5.0 by ggregoire on Thursday March 16, 2023 @04:01PM (#35187588)
Your experience probably differs from people who like TS. Personally I don't feel any hassle from using it and I couldn't even start listing all the benefits I get. Even if I know that my new project will have like 3 files and 200 LOC, first thing I'm doing is installing TS.

Not saying it's your case, but I noticed that a lot of people who hate TS like to use techniques and patterns that are usually considered bad practices, which often trigger errors in TS. For examples, mutating an object to add a new property, mutating an array to add an element of a different type, etc.

I also noticed that lot of people who don't like TS think they need to type everything (every variable, every function's return... which is obviously a hassle) instead of relying on types inference. There is usually very little to type in TS (compared to Java or C# for example). The two main things are the parameters of your named functions and your external data (i.e. the fetch responses). Almost everything else can be inferred.

A last category of issues I see with a lot of people who hate TS is related to generics. They do everything they can to avoid using generics and they get very frustrated to not be able to reuse functions with arguments of different types. So instead they hack some workarounds together to avoid TS errors (which makes any future modification or refactoring even worse), usually by first defining the parameter as an union of types and then inserting @ts-ignore everywhere inside the function where TS still shows errors. Or they just copy/paste the function and change the function signature.

Re:TypeScript 5.0 by postdb on Friday March 17, 2023 @02:54AM (#35194078)
>Not saying it's your case, but I noticed that a lot of people who hate TS like to use techniques and patterns that are usually considered bad practices, which often trigger errors in TS. Mutating an object to add a new property, mutating an array to add an element of a different type, processing apples and oranges in the same function without using generics or the correct union type, etc. Code works but TS doesn't like it and forces them to rewrite it properly and it feels like a hassle with no benefits.

Not sure, people who like TS are usually for large corporate projects with OOP background. Most functional lispish type developer would be fine just using ES6 and above.