Skip to content

Add public #x #5

Description

@Igmat

We don't know what is private #x yet (I hope #4 will be answered soon), but it seems to be some kind of symbol.

It makes sense to have public #x notation in this case, doesn't it?
I propose it to be kinda like shorthand for const x = Symbol(). But in this case, it have much more sense to have class-fields affected like in #1.

Examples:

public #x;
existingObj.#y = 1; // throws because #y isn't declared yet
const obj = {
    #x: 1,
    public #y: 1,
};
const otherObj = {
    public #x: 1, // shadows `#x` from outer lexical scope
    #y: 1, //  throws because #y isn't declared yet in this scope
};
public #x;
existingObj.#y = 1; // throws because #y isn't declared yet
class SomeClass {
    #x = 1;
    public #y = 1;
};
class SomeOtherClass = {
    public #x = 1; // shadowed `#x` not shared with `SomeClass`
    public #y = 1; // another `#y` not shared with `SomeClass`
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions