Skip to content

@interface tag on discriminated union results in inappropriate broadening of some property types, omission of others #2352

Closed
@Oblarg

Description

@Oblarg

Consider:

type Foo = {
  key: 'foo'
  bar: 'bar1'
}

type Bar = {
  key: 'bar'
  bar: 'bar2'
  baz: any
}

/**
 * @interface
 */
type DiscriminatedUnion = Foo | Bar;

This renders as:

{
  key: 'foo' | 'bar'
  bar: 'bar1 | 'bar2'
}

The type above is overly-broad with respect to the key and bar properties (their values are correlated), and omits the baz property entirely.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions