Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@Igorbek

Description

@Igorbek
Issue body actions

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

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.