Skip to content

Partial type does not accept plain empty object literal as a default #9069

Open
@insonifi

Description

@insonifi

Flow version: 214

Expected behavior

The partial type also accepts object literal as a default value since it is an extreme case where all properties were omitted
<T>(Partial<T> = {}) => {}

Actual behavior

Flow throws an incompatible type error because the object literal is incompatible with {...T}. It can be circumvented by casting an any type to the object.

<T>(Partial<T> = ({}: any)) => {}

Flow try demo

Activity

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

    Typing: completenessNo false positives (type checker claims that there are some errors in the correct program)Typing: destructorsbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions