microsoft / microsoft/TypeScript
Module Namespace Exotic Objects are incorrectly typed as if they have an Object prototype
Open
Nobody has claimed this yet.
In Discussion
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.5.3
Search Terms:
- import hasOwnProperty
- import star hasOwnProperty
- namespace exotic object
- import prototype
Code
import * as Foo from "./Foo"
if (foo.hasOwnProperty("bar")) {
console.log(foo.bar)
}
Expected behavior:
Type error due to hasOwnProperty not existing, as the "module namespace exotic object" should have a null prototype.
Actual behavior:
Code runs producing runtime error that hasOwnProperty is undefined.
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 by reproducing the example with TypeScript 3.5.3 and inspect how an import * as Foo namespace is typed. The issue is done when the compiler reports an error for hasOwnProperty, matching the specified null-prototype runtime behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100