Skip to content

Overloads should be merged to consider whether a union-typed argument is valid #21175

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
pelotom opened this issue Jan 13, 2018 · 2 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@pelotom
Copy link

pelotom commented Jan 13, 2018

TypeScript Version: 2.7.0-dev.201xxxxx

Code

interface Foo {
  x: number
}

interface Bar {
  y: boolean
}

interface Baz {
  (foo: Foo): void
  (bar: Bar): void
}

declare const baz: Baz
declare const foobar: Foo | Bar

baz(foobar)

Expected behavior:

Should compile.

Actual behavior:

The last line has a type error,

Argument of type 'Foo | Bar' is not assignable to parameter of type 'Bar'.
  Type 'Foo' is not assignable to type 'Bar'.
    Property 'y' is missing in type 'Foo'.
@mhegazy
Copy link
Contributor

mhegazy commented Jan 16, 2018

Duplicate of #14107

@mhegazy mhegazy marked this as a duplicate of #14107 Jan 16, 2018
@mhegazy mhegazy added the Duplicate An existing issue was already created label Jan 16, 2018
@pelotom
Copy link
Author

pelotom commented Jan 16, 2018

Thanks for the pointer, closing.

@pelotom pelotom closed this as completed Jan 16, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants