tc39 / tc39/proposal-private-declarations

Add `public #x`

Open
#5 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
26
Forks
2
Avg merge
1m
Merged PRs (30d)
2

Description

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`
};

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named; begin with the examples in this issue and review issue #4, then compare the interaction with class fields described in #1. Done means the semantics for public private-name declarations and the object and class examples are agreed and documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.