Skip to content

Incorrect Object.assign return typeΒ #45215

Closed
@AndreyKuznetsovQS

Description

@AndreyKuznetsovQS

Bug Report

πŸ”Ž Search Terms

object.assign return type

πŸ•— Version & Regression Information

Faced this problem in the 4.3.2 version and checked on 4.3.5, 4.4.0-beta(problem still exists)

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type SomeData = { a: number };

const getSomeData = (): SomeData | undefined => {
  return undefined;
}

// expected data type: SomeData | undefined
// actual data type: SomeData
const data = Object.assign({}, getSomeData())

πŸ™ Actual behavior

Incorrect type inference

πŸ™‚ Expected behavior

Correct type inference

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