javascript class definition in Observable

can’t find any difference in standard class definition in Observable :frowning:

class User {
    #nameValue

    constructor(name) {
        this.name = name
    }

    get name() {
        return this.#nameValue
    }

    set name(name) {
        if (name === '') {
            throw new Error('Empty user name')
        }
        this.#nameValue = name
    }
}

const user = new User('username1')

static and private fields and method not supported.
what other restrictions are there, help please

Yes, Observable does not support class fields yet. I’m sorry, I’ve run into this limitation too, it’s annoying and it’s been true for a while. I’ve just reopened this old issue for it.

I don’t know if we currently have any comprehensive documentation of what’s unsupported but I can check. I just put a notebook of test cases for public and private class field syntaxes.

Of the syntax examples from MDN, the only one that currently works on Observable is:

class ClassWithPublicInstanceMethod {
  publicMethod() {
    return 'hello world'
  }
}
1 Like

i think that Observable using classes as syntax sugar on prototype entity. not new features of modern js standard.