Skip to content

Object.getPrototypeOf returns any instead of object | null #22875

@cshaa

Description

@cshaa

TypeScript Version: 2.7.2

Search Terms: Object.getPrototypeOf, ObjectConstructor.getPrototypeOf, wrong return type

Code

let prototype = Object.getPrototypeOf(foo);

Expected behavior:
The type of prototype should be object | null. According to the spec, getPrototypeOf returns the value of the internal property [[Prototype]] [1] whose values can only be of type object or null [2].

Actual behavior:
prototype has type any

Playground Link: here

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureBreaking ChangeWould introduce errors in existing codeSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions