Skip to content

Type Alias: OverloadParameters<TypeParameter>

OverloadParameters<TypeParameter> = Parameters<OverloadUnion<TypeParameter>>

Type utility for extracting parameters from function overloads. Useful for typed event emitters and other scenarios with overloaded functions.

This handles the complex case where a function has multiple overloads and you need to extract the parameter types for all possible overloads.

Type Parameters

TypeParameter

TypeParameter extends (...arguments_) => unknown

The overloaded function type

See

https://github.com/microsoft/TypeScript/issues/32164#issuecomment-1146737709

Example

typescript
// Overloaded function
declare function emit(event: 'click', x: number, y: number): void
declare function emit(event: 'change', value: string): void
declare function emit(event: 'error', error: Error): void

// Extract all possible parameter combinations
type EmitParams = OverloadParameters<typeof emit>
// Result: ['click', number, number] | ['change', string] | ['error', Error]

Released under the MIT License.