0

Why Params inferred as 3?

type IntersectionOfFunctions = ((a: 1) => void) & ((a: 2) => void) & ((a: 3) => void);

type Params = Parameters<IntersectionOfFunctions>; // why is this infered as 3 ???

How it works under hood?

Alexander Pankin
  • 475
  • 2
  • 10
  • How an intersection supposed to work with functions? Maybe you wanted to use a union? – Anatoly Oct 09 '21 at 14:13
  • I'm just wondering why it's done this way – Alexander Pankin Oct 09 '21 at 14:19
  • Specifically this quote from an answer in the above question is relevant: "Recall from earlier that an intersection of functions is considered to be an overloaded function. It is a known design limitation of TypeScript that when using type inference on an overloaded function type, the compiler does not try to resolve the overload by figuring out which call signature matches the intended inference best. It just uses the last call signature and ignores all the rest of them." – JKillian Oct 09 '21 at 16:29

0 Answers0