Skip to content

Clarify specification for “context.name” for private vs public elements.#570

Open
theengineear wants to merge 1 commit into
tc39:masterfrom
theengineear:patch-1
Open

Clarify specification for “context.name” for private vs public elements.#570
theengineear wants to merge 1 commit into
tc39:masterfrom
theengineear:patch-1

Conversation

@theengineear

@theengineear theengineear commented Dec 10, 2025

Copy link
Copy Markdown

The babel transpiler I’m using appears to always return a string here (even for private elements). When I looked back at this proposal, it felt like there was potentially room for interpretation!

This attempts to make two things more explicit:

  1. If the element is private, context.name returns a Symbol, not a String.
  2. And, if the element is private context.name.description is a #-prefixed string mirroring the name provided by the developer.
class Example {
  @decorator
  accessor #field;  // Expected: context.name = Symbol('#field')
                    // ✗ Babel:  context.name = '#field'

  @decorator
  accessor field;   // Expected: context.name = 'field'
                    // ✔ Babel:  context.name = 'field'
}

The babel transpiler I’m using appears to always return a _string_ here (even for private elements). When we looked back at this proposal, it felt like there was potentially room for interpretation!

This attempts to make two things more explicit:
1. If the element is private, `context.name` returns a `Symbol`, not a `String`.
2. And, if the element is private `context.name.description` is a `#`-prefixed string mirroring the name provided by the developer.
@theengineear

theengineear commented Dec 10, 2025

Copy link
Copy Markdown
Author

Feel free to close this, I found myself trying to write an issue for this… but it felt much easier to ask this question over code. I wanted to clarify the intent here first before potentially opening an issue in the babel transpiler (if this is even something that can be accomplished via transpilation). Thanks for taking a look and apologies for the noise I’ve been making!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant