News for hackers. Stuff that matters.
Re:What the heck are reverse mapped types? by tobyhinloopen on Sunday August 18, 2024 @01:42AM (#41280358)
Alternative title: how to write unmaintainable, unreadable code that nobody understands and cannot be fixed or modified without introducing compiler errors for code that just works.

These features are why I don’t like Typescript. It is too complicated.

Re:What the heck are reverse mapped types? by epolanski on Sunday August 18, 2024 @03:24AM (#41280754)
There's so many things wrongs in your post imho:

1) the destructive yet not helpful nature of your post. What are better alternatives to write JavaScript than TS? Elm and flow are not.

2) not realizing that any powerful type system (or language) has advanced concepts, this isn't exclusive to TypeScript

3) Not realizing this is mostly a tool for library authors to provide better inference to API consumers

4) Last but not least, 99% of TypeScript users can't even tell what a mapped type is (it's in the docs) nor define it or say when to use it, people don't even bother to read the docs fundamentals so attitudes like yours are unsurprising

5) Typescript is verbose, but very simple to follow and read if you know the basics. It's unmaintainable only because people don't bother to master any topic

Re:What the heck are reverse mapped types? by toolslive on Sunday August 18, 2024 @04:54AM (#41281087)
> What are better alternatives to write JavaScript than TS? Elm and flow are not.

Why do you want to write javascript ? Most self-respecting programming languages have a javascript backend (Let's list a few pretty ones: Rust, OCaml, Haskell). There's no need to manually generate javascript and you can treat it like you would treat assembly language: something you don't want to touch 99% of the time.

Re:What the heck are reverse mapped types? by epolanski on Sunday August 18, 2024 @12:35PM (#41283356)
None of the languages you list allow a small team to move ahead web, native and server code with ease.

None of the languages you list make hiring easy, at all.

None of the languages you list are easy to setup across platforms/cloud environments.

None of the languages you list make handling a monorepo simple.

I am most certain (I know Haskell, lisps, Elm, C, Java, Scala) that there are different good tools for different use cases, but I ain't picking any of those 9 times out of 10 without a solid reason to do so in the context of web development.

Re:What the heck are reverse mapped types? by BenoitP on Sunday August 18, 2024 @02:26AM (#41280536)
> It is too complicated.

I wouldn't say this. It can bring complications, yes: but only because like a lot of expressive tools people will over-engineer things with them (probably like this sentence)

To me, Typescript saved JavaScript from under-constraining. It's bringing me some peace of mind.

Re:What the heck are reverse mapped types? by ngruhn on Sunday August 18, 2024 @02:54AM (#41280635)
I think using more descriptive type parameter names (instead of just T, K, F, …) already goes half way reducing the complexity.
Re:What the heck are reverse mapped types? by mrkeen on Sunday August 18, 2024 @04:13AM (#41280933)
OK so what would you call them? TypeParam1, TypeParam2, ... ?
Re:What the heck are reverse mapped types? by code_biologist on Sunday August 18, 2024 @05:02AM (#41281116)
A common convention I've seen is using T at the start of a type parameter, [1] for example. TKey, TData, TError, TSuccessCallback, etc. I always liked T at the end, but I've not seen that as often.

[1] https://github.com/TanStack/query/blob/59a6d3df3035d6effeaed...

Re:What the heck are reverse mapped types? by toastedwedge on Sunday August 18, 2024 @10:47AM (#41282695)
Seems apt that the error for a generic type would (and should) be spelled "terror."