Skip to content

Union of objects with union property is not eliminated #51552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
awerlogus opened this issue Nov 16, 2022 · 2 comments
Closed

Union of objects with union property is not eliminated #51552

awerlogus opened this issue Nov 16, 2022 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@awerlogus
Copy link

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

@MartinJohns
Copy link
Contributor

Duplicate of #43026 (comment).

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Nov 17, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants