Skip to content

union type {x, y} | {x, z} sometimes incorrectly allows {x, y, z}Β #43691

@felix9

Description

@felix9

Bug Report

πŸ”Ž Search Terms

union type

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about union types

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type XY<T> = {
    x: T;
    y: T;
};
type XZ<U> = {
    x: U;
    z: U;
};

// This is correctly an error
const a: XY<boolean> | XZ<string> = { x: true, y: true, z: 'z' };

// This is incorrectly allowed
const b: XY<number> | XZ<string> = { x: 1, y: 1, z: 'z' };

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