microsoft / microsoft/TypeScript
Existential type?
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
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;
patchEnd?(): void;
patchAdd?(
prev: string | E | void,
next: string | E | void,
pos: number,
): void;
patchRemove?(
prev: string | E | void,
next: string | E | void,
pos: number
): void;
patchChange?(
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>
);
// ...
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the existential-type examples in the issue. No source file, test, or entry point is named, so identify the TypeScript type-system and declaration-processing areas involved before assessing the design. Done would mean supporting the requested existential parameters while preserving the internal relationships between Binding and Scheduler types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100