Skip to content

Regression: intersection of a generic type bound to a discriminated union with one of the union constituencies reduces to never #38549

Closed
@Igorbek

Description

@Igorbek

TypeScript Version: 3.9.2

Search Terms: Generic union intersection

Code

interface A {
  kind: "A";
  a: number;
}

interface B {
  kind: "B";
  b: number;
}

declare const shouldBeB: (A | B) & B;
const b: B = shouldBeB; // works

function inGeneric<T extends A | B>(alsoShouldBeB: T & B) {
  const b: B = alsoShouldBeB;
  //    ~ TS2739: Type 'T & B' is missing the following properties from type 'B': kind, b
}

Expected behavior:

No errors (were no errors on 3.8)

Actual behavior:

TS2739: Type 'T & B' is missing the following properties from type 'B': kind, b

Playground Link: link

Related Issues:

It seems to be related to #36696

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions