Skip to content

Correct props helper on discriminated/tagged union type #24763

@wclr

Description

@wclr

TS proposes all the props from intersection of the discriminated/tagged union type, but should be proposing on props of determined type.

image

interface Square {
  kind: "square";
  size: number;
}

interface Rectangle {
  kind: "rectangle";
  width: number;
  height: number;
}

interface Circle {
  kind: "circle";
  radius: number;
}

type Shape = Square | Rectangle | Circle;

let shape: Shape = {
  kind: "square",  
  // should propose only `size`
}

Ts 2.9.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions