Online IDE loses ability to run functions when the following code is loaded

Viewed 189

I have narrowed the problem or bug to be triggered by either of the two commented lines being uncommitted. I was unable to find any similar questions but somebody else might have better search ability than I do.

Using the new runtime (Chrome V8) I am currently testing how to implement classes to an existing project but this testing is being done in it's own environment.

class test{

    //publicFoo = 321;   // <---- these two lines
    //#privateFoo = 456;

    constructor(){
        Logger.log("test created");
        this.foo = 123;   

    }

    getfoo(){
        return this.foo;
    }

    getPrivateFoo(){
        //return this.#privateFoo;
    }

}

function myClassTester(){
        const myTest = new test();

        Logger.log("myTest.foo: " + myTest.foo );
        Logger.log("myTest.getfoo(): " + myTest.getfoo() );
        Logger.log("myTest.publicFoo: " + myTest.publicFoo );
        Logger.log("myTest.privateFoo: " + myTest.privateFoo );
        Logger.log("myTest.getPrivateFoo(): " + myTest.getPrivateFoo() );

}

picture, no issues with the lines commented

picture, no functions to run when un commented

While verifying to write the question here I have also noticed if you do the edit online vs in clasp it does throw

Error: Line 3: Unexpected token = (line 2021, file "esprima.browser.js-bundle.js")

on saving...

Link to issue tracker ticket. https://issuetracker.google.com/150896358

1 Answers

Explanation

At the moment private member variables are not supported.

Moreover, as a broad recommendation from the original poster, any member variable should be declared in the constructor of the class.

This solution was brought to you by the original poster and those users that participated in the comment section

Related