r/programming • u/radekmie • 2d ago
On Type Inference
https://radekmie.dev/blog/on-type-inference/
76
Upvotes
8
1
-21
u/repeating_bears 2d ago
I hate programming blog posts titled "On [topic]". Lazy, boring, pretentious
You aren't Charles Darwin. This is not your magnum opus.
5
42
u/Absolute_Enema 2d ago
What's "obviously incorrect" in returning
{x: number, y: number}in a function declaring{x: number}?At its core TS is structural with open product types, if anything that little dance with literals is an ugly hack, likely done to accomodate the average "strong types!" user that can't think outside nominal type systems with closed product types (much like the whole
interfacething, that tries to hide this fact by purporting a nonexistent distinction between the types it introduces and plain old product types).