4 ms·
The naming of TypeScript Union and Intersection types, with respects to type theory, used to be terribly confusing/contradictory: https://www.typescriptlang.or
by redbar0n 4y ago
The naming of TypeScript Union and Intersection types, with respects to type theory, used to be terribly confusing/contradictory:
https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html https://www.typescriptlang.org/docs/handbook/unions-and-inte...
See last paragram under «Unions with common fields»
Leading to terribly confusing TypeScript cheat sheets such as this (see the union and intersection venn-diagrams):
https://carltheperson.com/images/magic-typescript/magic-typescript.png https://carltheperson.com/images/magic-typescript/magic-type...
Compare with:
https://en.wikipedia.org/wiki/Intersection_(set_theory) https://en.wikipedia.org/wiki/Intersection_(set_theory)
Luckily TypeScript recently updated their docs, and the issue has been clarified in posts such as this:
https://stackoverflow.com/questions/38855908/naming-of-typescripts-union-and-intersection-types/70513147#70513147 https://stackoverflow.com/questions/38855908/naming-of-types...
Turns out, naming things is really hard, because what you implicitly refer to when you unionize or intersect turns out to be of vital importance.
- mbrodersen 4y agoI agree. I wish the Typescript team had simply embraced Dependent Types from the beginning instead of adding a laundry list of ad-hoc solutions with special syntax. It’s already way more complicated than it needs to be. Solving a problem you can either use a simple but powerful solution or add patch after patch forever until you kinda sorta have covered everything that the simple powerful solution would have given you. It looks as if Typescript unfortunately is going down the patches route requiring cheat sheets and memorisation to work with. Exactly what happened with C++ templates.