microsoft / microsoft/TypeScript
Object.defineProperty doesn't define properties on 'this'
Open
Nobody has claimed this yet.
Awaiting More Feedback
Domain: JavaScript
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
// @ts-check
class C {
constructor() {
Object.defineProperty(this, "x", { value: "hello" });
this.x.toLowerCase();
}
}
Expected: No error.
Actual: Property 'x' does not exist on type 'C'.
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 @ts-check example and confirm the diagnostic for this.x after Object.defineProperty(this, "x", ...). Trace the TypeScript checker path handling Object.defineProperty and class-instance properties; done means the example type-checks without the reported error while preserving the shown behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100