Skip to content

Impossible to spread <T extends object> #24630

Closed
@alex-kinokon

Description

@alex-kinokon

TypeScript Version: 2.9.1

Search Terms:
object type, generic, spread, error

Code

function test<T extends object>(a: T) {
    return { ...a };
}

Expected behavior:
No error.

Actual behavior:
Error: Spread types may only be created from object types.

Playground Link:
Here you go.

Related Issues:
None found so far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions