ES6 and Object.defineProperties issue
See original GitHub issuelets say i have the following class:
class Object3D extends EventDispatcher {
constructor() {
super();
const quaternion = new Quaternion();
Object.defineProperties( this, {
quaternion: {
configurable: true,
enumerable: true,
value: quaternion
}
} );
}
onRotationChange() {
this.quaternion.setFromEuler(........);
}
}
and the following warning:
core/Object3D.js:123:7: WARNING - [JSC_INEXISTENT_PROPERTY] Property quaternion never defined on Object3D
123| this.quaternion.setFromEuler();
^^^^^^^^^^
I have no idea what i do wrong, maybe i missed something ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Object.defineProperties() - JavaScript - MDN Web Docs
The Object.defineProperties() method defines new or modifies existing properties directly on an object, returning the object.
Read more >Object.defineProperty sometimes throws - Stack Overflow
I am playing with ES6 classes and non-writable properties. As an example, I have the following code. I am running it under node...
Read more >JavaScript ES5: Meet the Object.defineProperty() Method
This tutorial explains how and why to use the Object.defineProperty() method in JavaScript ES5. It may sound like a complicated thing... until you...
Read more >Object.defineProperty in class constructor - Google Groups
The compiler does not understand these constructs well. ES6 getter and setters are transformed to Object.defineProperties(…) through transpilation. Currently, ...
Read more >14. New OOP features besides classes - Exploring JS
Object.setPrototypeOf(obj, proto). 14.4. Traversing properties in ES6 ... There is also a way to concisely define properties whose values are generator ...
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
Just want to add, the compiler recognizes properties creates by
Object.defineProperties
during optimizations, but not during typechecking. As such, we believe things are working as intended.That distinction might feel arbitrary, but optimizations generally require less information about properties (usually just “does this name exist somewhere in the program?”) so it’s easier to add support. Recognizing them during typechecking is more nuanced.
Additionally, optimization failure can cause runtime behaviour issues, so we need to be very conservative, and often silently cancel optimizations when something might be wrong. In contrast, typechecking failure is a compile-time problem, so we can make it more user visible, and defer to the user (via suppressions or annotations) when we get false positives.
@ctjlewis thanks for your clarification, so it means closure ignores Object.defineProperties/Object.defineProperty ? Ok, i am working on three.js and i didn’t want to change the code too much but looks like i have no choice to make it closure compatible.