The Curious Case of Type Inference in TypeScript
Published in
7 min readOct 9, 2023
Some time ago, I was working on a side project. It used one specific library with many events to listen to.
I wanted to use the same event kinds in my project so I do not reinvent the wheel.
The library creators buried them as the first parameter of an overloaded event listener function, like this:
type OverloadedFunction = {
(event: 'eventA'): void;
}
I thought it would take less than mere seconds to import the proper type definitions and move on.