Skip to content

Support private properties syntax #2896

Open

Description

@lloydjatkinson

Feature suggestion

Support private properties: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_properties

Example:

class Class {
    #example: i32;
}

Activity

  1. mattjohnsonpint commented on Mar 25, 2025

    @mattjohnsonpint
    Contributor

    Is this just a request to support the # syntax instead of private? Or would you expect a difference in functionality?

    Considering the feature overview from the TypeScript 3.8 release notes (when it was added), in TypeScript private is "soft privacy" where # is "hard privacy". But in AssemblyScript, since there's no JS transpile, then I believe private is already "hard privacy".

  2. MichaelTheriot commented on Jul 13, 2025

    @MichaelTheriot

    I do not use private in TypeScript as # supersedes it, so this is useful at least for consistent code style.

    I think the only functional difference without JS transpile is #x in y should evaluate to y instanceof this.constructor.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions