-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
SuggestionAn idea for TypeScriptAn idea for TypeScript
Description
We can kind of already do this for functions by defining several overloads, but there is no corresponding mechanism for overloaded classes or interfaces. A typical use case would be defining a registry for callbacks which accept a number of parameters. Something like the following with loosely proposed variadic type syntax:
interface IDispatcher<...ArgTypes> {
add(callback: (...args: ArgTypes) => void): void {
// store the callback
}
dispatch(...args: ArgTypes): void {
// invoke the callbacks
}
}
function createDispatcher<...ArgTypes>(): IDispatcher<...ArgTypes> {
// create a concrete instance
}
var d = createDispatcher<number, string>();
zkochan, sethbrenith, elldritch, Thomas-Sparber, rebelwolfson and 8 more
Metadata
Metadata
Assignees
Labels
SuggestionAn idea for TypeScriptAn idea for TypeScript