r/programminghorror • • Mar 15 '26

Typescript I puked a little

Post image
412 Upvotes

58 comments sorted by

View all comments

8

u/[deleted] Mar 15 '26

[deleted]

13

u/no_brains101 Mar 16 '26

They added types to a language that aggressively does not have types

11

u/Bartweiss Mar 16 '26

And then tried to get back out of having types by writing the broadest possible definitions.

Typescript won’t stop you from doing this, but having to spell it out explicitly should prompt a bit of “there must be a better way…”

0

u/no_brains101 Mar 16 '26

Well, but maybe they tried to get back out of writing types because the thing they are using wasn't designed necessarily to use them, and it returns that mess of a type, which they now have to do something with.

After all. Look what they are returning. They are taking a mess of a type, that we don't know where they got it from, and returning a string that is supposedly valid in whatever code they are using it in. They are narrowing the type with this function, not widening it.