Open
Description
Here's a case where I need a few existentials. It's for a definition file, where I need to have parameters for Binding
and Scheduler
, but it doesn't matter to me what they are. All I care about is that they're internally correct (and any
doesn't cover this), and I'd rather not simulate it by making the constructor unnecessarily generic.
The alternative for me is to be able to declare additional constructor-specific type parameters that don't carry to other methods, but existentials would make it easier.
export interface Scheduler<Frame, Idle> {
nextFrame(func: () => any): Frame;
cancelFrame(frame: Frame): void;
nextIdle(func: () => any): Idle;
cancelIdle(frame: Idle): void;
nextTick(func: () => any): void;
}
export interface Binding<E> extends Component {
binding: E;
End?(): void;
Add?(
prev: string | E | void,
next: string | E | void,
pos: number,
): void;
Remove?(
prev: string | E | void,
next: string | E | void,
pos: number
): void;
Change?(
oldPrev: string | E | void,
newPrev: string | E | void,
oldNext: string | E | void,
newNext: string | E | void,
oldPos: number,
newPos: number
): void;
}
export class Subtree {
constructor(
onError?: (err: Error) => any,
scheduler?: type<F, I> Scheduler<F, I>
);
// ...
}
export class Root extends Subtree {
constructor(
component: type<E> Binding<E>,
onError?: (err: Error) => any,
scheduler?: type<F, I> Scheduler<F, I>
);
// ...
}