Skip to content

(🐞) No error when assigning to a member of a union that has different types in each part of the union #50384

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
KotlinIsland opened this issue Aug 21, 2022 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@KotlinIsland
Copy link

KotlinIsland commented Aug 21, 2022

Bug Report

πŸ”Ž Search Terms

union container assignment

πŸ•— Version & Regression Information

v4.8.0-beta

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about: generic unions

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

class A {
    t!: number
}

class B {
    t!: string
}

declare let a: A | B
a.t = "a string?"

πŸ™ Actual behavior

No error when assigning a string to the incompatible item of the union (number)

πŸ™‚ Expected behavior

An error regarding the invalid assignment.

@MartinJohns
Copy link
Contributor

MartinJohns commented Aug 21, 2022

Pretty sure it's a duplicate of #50249.

@KotlinIsland KotlinIsland changed the title (🐞) No error when assigning to a union of two types with different type parameters (🐞) No error when assigning to a member of a union that has different types in each part of the union Aug 22, 2022
@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Aug 25, 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