assemblyscript icon indicating copy to clipboard operation
assemblyscript copied to clipboard

Support private properties syntax

Open lloydjatkinson opened this issue 10 months ago • 2 comments

Feature suggestion

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

Example:

class Class {
    #example: i32;
}

lloydjatkinson avatar Jan 19 '25 18:01 lloydjatkinson

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".

mattjohnsonpint avatar Mar 25 '25 21:03 mattjohnsonpint

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.

MichaelTheriot avatar Jul 13 '25 14:07 MichaelTheriot