microsoft / microsoft/TypeScript
Object.getPrototypeOf returns `any` instead of `object | null`
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the ObjectConstructor.getPrototypeOf entry point and reproduce the example in the TypeScript playground. Check the declared return type against the ECMAScript behavior described in the issue; done means the inferred type is object | null rather than any.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100