Skip to content

Spread object type inference errorΒ #51253

@wmzy

Description

@wmzy

Bug Report

πŸ”Ž Search Terms

πŸ•— Version & Regression Information

TS version: 4.8.4

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type T = {
  foo?: string;
};

const a: T = {foo: undefined};
const b = {foo: '', ...a};

πŸ™ Actual behavior

image

πŸ™‚ Expected behavior

The type of b should be:

{
  foo?: string;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions