Object.defineProperty doesn't define properties on 'this'
See original GitHub issue// @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'.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Object.defineProperty() - JavaScript - MDN Web Docs
When the property specified doesn't exist in the object, Object.defineProperty() creates a new property as described.
Read more >Why does object.defineproperty not add the property to the ...
Object.defineProperty defines non enumerable properties unless the descriptor overrides the default value ( false ) for enumerable . var ...
Read more >Object.defineProperty() - Javascript - CodeProject Reference
The Object.defineProperty() method defines a new property directly on an object, or modifies an existing property on an object, and returns the object....
Read more >11 Properties: assignment vs. definition - Exploring JS
There are two ways of creating or changing a property prop of an object obj : Assigning: obj.prop = true; Defining: Object.defineProperty(obj, '',...
Read more >JavaScript Object defineProperty() Method - Javatpoint
The Object.defineProperty() method defines a new property directly on an object and returns the object. To change the flags, we can use Object.defineProperty....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tokland This is about JavaScript analysis, not TypeScript.
You need to add definite assertion assignment to property ‘x: string’.