Dev Tools · 2h ago
TypeScript Overload Inference: Order Matters
A developer discovered that TypeScript infers only the last overload signature when extracting call signatures from overloaded function types. To work around this, they changed the order of overloads to prioritize the most specific signature. The fix improves type inference for libraries like i18next that use overloaded functions.
Meridian48 take
This is a practical, if hacky, workaround that highlights a long-standing limitation in TypeScript's type system—useful for library authors but not a permanent solution.
Read the full reporting
TypeScript Infers the Last Overload... So I Changed the Order →
DEV Community
typescripttype-inference