Closed
Description
openedon Jan 22, 2015
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>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment