-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
Needs InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
Description
Bug Report
π Search Terms
Enum refinement, enum unification, enum constant,
π Version & Regression Information
3.3 and up, as far back as I could test it
β― Playground Link
Playground link with relevant code
π» Code
const enum ToRefine {
One,
Two
}
type Refine<R extends ToRefine> = R extends ToRefine.One ? number : R extends ToRefine.Two ? string : never;
type RefineAny = Refine<ToRefine>;
function refined(param: Refine<ToRefine.One>) {
return param + 1;
}
function callRefined(value: RefineAny) {
refined(value)
}
interface Container<R extends ToRefine> {
option: Refine<R>
}
type ContainerAny = Container<ToRefine>;
function contained(param: Container<ToRefine.One>) {
return param.option + 1;
}
function callContained(value: ContainerAny) {
contained(value)
}π Actual behavior
callRefined fails to typecheck due to a type mismatch as expected
callContained passes the typechecker when it shouldn't
π Expected behavior
Both callRefined and callContained should fail to typecheck
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone