Skip to content

Union of objects with union property is not eliminatedΒ #51552

Closed
@awerlogus

Description

@awerlogus

Bug Report

πŸ”Ž Search Terms object property union elimination

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type A = { a: '1', b: string } | { a: '2' | '3' }

declare const a: A

if (a.a !== '2' && a.a !== '3') {
  // (property) a: "1"
  a.a

  // Property 'b' does not exist on type 'A'.
  //   Property 'b' does not exist on type '{ a: "2" | "3"; }'.(2339)
  a.b
}

πŸ™ Actual behavior

Error: Property 'b' does not exist on type 'A'.

πŸ™‚ Expected behavior

No error

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions