Skip to content

Object.create return type #3865

@matthewjh

Description

@matthewjh

Hi,

Just curious as to the reasoning behind Object.create having a return value of type any in lib.d.ts.

Wouldn't this make more sense?

create<T extends A>(o: A, properties?: PropertyDescriptorMap): T;

since the returned object is guaranteed to have the properties of o through prototypal inheritance.

At present I'd like to create many objects (via literals) of type X, but given that many of the properties are shared, using Object.create makes a lot of sense. It seems a shame that I must use this at the expense of typing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions