Skip to content

Some identical types not being merged when one is optional in an object spreadΒ #45692

Closed
@ghost

Description

Bug Report

πŸ”Ž Search Terms

merging object spread

πŸ•— Version & Regression Information

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

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

declare const A: {foo: () => void}
declare const B: {foo?: () => void}

const C = {...A, ...B};

πŸ™ Actual behavior

const C: {
    foo: (() => void) | (() => void);
}

πŸ™‚ Expected behavior

const C: {
    foo: () => void;
}

Notes

Note that this merges primitives, but not functions or objects as far as I can tell

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions