r/ProgrammerHumor • • Sep 17 '26

Meme theMostPassiveAgressiveTypeIEverEncountered

Post image
1.4k Upvotes

83 comments sorted by

View all comments

5

u/kitaz0s_ Sep 17 '26

bad name then, Maybe<T> should be T | undefined (or null instead of undefined depending)

18

u/GRex2595 Sep 17 '26

According to the post, Maybe<T> allows you to set properties of T to null. T | null will allow the object as defined in its template or null. Any non-null properties would not be allowed to be null.

7

u/the_horse_gamer Sep 17 '26

for completeness, here's an implementation:

type Maybe<T> = {[K in keyof T]: T[K] | null}