I want to use static class properties (stage-0) in ES6 classes like so -
class Button {
static size = {
SMALL: "SMALL",
BIG: "BIG"
}
}
class UILibrary {
consturctor() {
this.button = new Button();
}
}
// I can't access static properties of a class instance :(
const LibraryA = new UILibrary();
console.log(LibraryA.button.size.SMALL);
What is the best alternative for this?
EDIT:
This question is not about creating class properties in ES6/7 which is already supported in stage-0, nor about creating static methods. I am just looking to find a pattern that allows attaching of enum-like objects to class instances. Hence none of the duplicate question suggestions are valid.