10000 Overloads should be merged to consider whether a union-typed argument is valid · Issue #21175 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
Overloads should be merged to consider whether a union-typed argument is valid #21175
Closed
@pelotom

Description

@pelotom

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'.

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

      0