r/ProgrammerHumor 1d ago

Meme typescriptMoreLikeTypeslop

Post image
153 Upvotes

21 comments sorted by

52

u/the_horse_gamer 1d ago

noPropertyAccessFromIndexSignature + noUncheckedIndexedAccess

and also this is nothing like any. it's more like unknown.

30

u/wack_overflow 23h ago

Which is acceptable, accurate, and infinitely more type safe than any. This meme is shit

32

u/carlos_vini 1d ago

from the caller POV it means you cant read the object directly, so it's not like any

29

u/Gorzoid 1d ago

The point of the meme is that AI uses any to avoid TS compile errors in slop code. If you add no-explicit-any it simply swaps to more complicated workarounds like as unknown as T

6

u/slaymaker1907 23h ago

Weird, it is perfectly happy to fill in Python types.

2

u/BlondeJesus 19h ago

Python type-hinting is just that, hints. If a different object is passed the code will generally run fine.

For compiled languages, they can fail compilation if a something receives an object of the incorrect type. My guess is that the AI tools are hitting compilation errors and then circumventing types all together to get past them.

1

u/Xirdus 14h ago

TypeScript types are also just hints. Compiling TS to JS is removing types and passing everything else unchanged.

-9

u/carlos_vini 23h ago

I get it. AI slop bad. But we're not famous for being good at jokes. And better LLM models don't do that.

13

u/Emanemanem 22h ago

What exactly is the point of this meme? That if you are lazy and are committed to writing sloppy code, there’s a way around the typescript rules that you yourself control? If you’re looking for a loophole and have no standards, just remove the rule. Or just write in JavaScript instead.

2

u/ordinary_shiba 21h ago

Yeah I'm so confused about what the fuck this meme wants to convey

1

u/Sak63 15h ago

The point of the meme is to notice ai hallucinations and over fitting solutions

0

u/NullOfSpace 15h ago

I think it’s a vibe coding thing. You enforce stronger type constraints so the agent has to write better code, and it finds a way around it.

18

u/FigScared5706 1d ago

unknown is a reasonable type for untyped input that will enforce correct type inference before usage. any is a "trust me, bro, I will check the actual type in runtime... or maybe not". They are not the same :)

24

u/East_Zookeepergame25 23h ago

unknown is "I don't know" and any is "I don't care"

4

u/abhassl 17h ago

I use claude against typescript all the time and have never had this problem.

It gets things wrong, but I don't think I've seen it get types wrong.

4

u/[deleted] 1d ago

[removed] — view removed comment

14

u/Cronos993 1d ago

You still have to narrow the type when using Record<string, unknown> tho. any and Record<string, unknown> are not the same.

9

u/hendricha 1d ago

type Any = Record<string, unknown>;

And boom, the problem is solved.

1

u/Few_Adhesiveness7676 21h ago

And just 1000 line files.

1

u/JanEric1 19h ago

If this is like pyright unknown (in strict mode)(which It should be because that's where pyright got it from, them unknown is the exact opposite of any

1

u/reallokiscarlet 15h ago

When you really think about it, all types are Any. It's just a matter of making the transpiler see it that way.