1

How would you explain/describe/narrate/parse in your head the following TypeScript expression:

export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;

(It is defined here and is located in the index.d.ts file)

Even though, questions one and question one explain what and how unions work, I am mostly curious how would one parse this particular TS expression.

jcalz
  • 264,269
  • 27
  • 359
  • 360
tonkatata
  • 369
  • 5
  • 21
  • 2
    That's really funny since I explained it in the second half of [this answer](https://stackoverflow.com/a/74451147/18244921) earlier today. – kelsny Nov 15 '22 at 20:56
  • 1
    Or see [this answer](https://stackoverflow.com/questions/57103834/typescript-omit-a-property-from-all-interfaces-in-a-union-but-keep-the-union-s) by jcalz which answers the same thing. – kelsny Nov 15 '22 at 20:57
  • 1
    "Given `T` and some potential keys, distribute over `T` and return `Omit`." is how I would think about it... but that's clearly lacking a lot of detail. This is really a more opinionated question now, which is not really suitable for Stack overflow. – kelsny Nov 15 '22 at 21:48

0 Answers0