Skip to content

Interface unions type checking #17256

Description

@jspri

TypeScript Version: 2.4.0

Code

interface Foo {
  a: string;
}

interface Bar extends Foo {
  b: string;
  c: string;
}

// d is neither foo nor bar!
const d: Foo | Bar = {
  a: 'lol',
  b: 'kek',
};

Expected behavior:

You would expect the code above to throw an error as d can not be resolved to type foo or type bar.

Actual behavior:

Code compiles without error.

Activity

  1. jcalz commented on Jul 18, 2017

    @jcalz
    Contributor

    duplicate of #14383?

  2. jspri commented on Jul 18, 2017

    @jspri
    Author

    Yeah, thanks.

  3. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions