|
| 1 | +//// [tests/cases/compiler/privateFieldsInClassExpressionDeclaration.ts] //// |
| 2 | + |
| 3 | +//// [privateFieldsInClassExpressionDeclaration.ts] |
| 4 | +export const ClassExpression = class { |
| 5 | + #context = 0; |
| 6 | + #method() { return 42; } |
| 7 | + public value = 1; |
| 8 | +}; |
| 9 | + |
| 10 | +// Additional test with static private fields |
| 11 | +export const ClassExpressionStatic = class { |
| 12 | + static #staticPrivate = "hidden"; |
| 13 | + #instancePrivate = true; |
| 14 | + public exposed = "visible"; |
| 15 | +}; |
| 16 | + |
| 17 | +//// [privateFieldsInClassExpressionDeclaration.js] |
| 18 | +var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) { |
| 19 | + if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; |
| 20 | + return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); |
| 21 | +}; |
| 22 | +var _instances, _context, _method, _a, _b, _ClassExpressionStatic_staticPrivate, _ClassExpressionStatic_instancePrivate; |
| 23 | +export const ClassExpression = (_a = class { |
| 24 | + constructor() { |
| 25 | + _instances.add(this); |
| 26 | + _context.set(this, 0); |
| 27 | + this.value = 1; |
| 28 | + } |
| 29 | + }, |
| 30 | + _context = new WeakMap(), |
| 31 | + _instances = new WeakSet(), |
| 32 | + _method = function _method() { return 42; }, |
| 33 | + _a); |
| 34 | +// Additional test with static private fields |
| 35 | +export const ClassExpressionStatic = (_b = class { |
| 36 | + constructor() { |
| 37 | + _ClassExpressionStatic_instancePrivate.set(this, true); |
| 38 | + this.exposed = "visible"; |
| 39 | + } |
| 40 | + }, |
| 41 | + _ClassExpressionStatic_instancePrivate = new WeakMap(), |
| 42 | + __setFunctionName(_b, "ClassExpressionStatic"), |
| 43 | + _ClassExpressionStatic_staticPrivate = { value: "hidden" }, |
| 44 | + _b); |
| 45 | + |
| 46 | + |
| 47 | +//// [privateFieldsInClassExpressionDeclaration.d.ts] |
| 48 | +export declare const ClassExpression: { |
| 49 | + new (): { |
| 50 | + "__#private@#context": number; |
| 51 | + "__#private@#method"(): number; |
| 52 | + value: number; |
| 53 | + }; |
| 54 | +}; |
| 55 | +export declare const ClassExpressionStatic: { |
| 56 | + new (): { |
| 57 | + "__#private@#instancePrivate": boolean; |
| 58 | + exposed: string; |
| 59 | + }; |
| 60 | + "__#private@#staticPrivate": string; |
| 61 | +}; |
0 commit comments