or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

array-helpers.mdasync-generators.mdclass-helpers.mddecorators.mdindex.mdmodule-interop.mdobject-helpers.mdprivate-members.mdresource-management.mdtype-utilities.md
tile.json

private-members.mddocs/

Private Fields and Methods Helpers

Private member helpers provide support for JavaScript private fields and methods, including access control, brand checking, and initialization patterns for both instance and static private members.

Capabilities

Private Field Access

classPrivateFieldGet

Gets the value of a private field from an instance.

/**
 * Gets private field value
 * @param receiver - Instance containing the private field
 * @param privateMap - WeakMap storing private field values
 * @returns Private field value
 */
function classPrivateFieldGet(receiver: any, privateMap: WeakMap<any, any>): any;

classPrivateFieldGet2

Alternative private field getter implementation.

/**
 * Alternative private field getter
 * @param receiver - Instance containing the private field
 * @param privateMap - WeakMap storing private field values
 * @returns Private field value
 */
function classPrivateFieldGet2(receiver: any, privateMap: WeakMap<any, any>): any;

classPrivateFieldSet

Sets the value of a private field on an instance.

/**
 * Sets private field value
 * @param receiver - Instance to set private field on
 * @param privateMap - WeakMap storing private field values
 * @param value - Value to set
 * @returns The set value
 */
function classPrivateFieldSet(receiver: any, privateMap: WeakMap<any, any>, value: any): any;

classPrivateFieldSet2

Alternative private field setter implementation.

/**
 * Alternative private field setter
 * @param receiver - Instance to set private field on
 * @param privateMap - WeakMap storing private field values  
 * @param value - Value to set
 * @returns The set value
 */
function classPrivateFieldSet2(receiver: any, privateMap: WeakMap<any, any>, value: any): any;

Private Field Initialization

classPrivateFieldInitSpec

Initializes private field specifications for a class.

/**
 * Initializes private field specs
 * @param obj - Object to initialize private fields on
 * @param privateMap - WeakMap for storing private values
 * @param value - Initial value for the private field
 */
function classPrivateFieldInitSpec(obj: any, privateMap: WeakMap<any, any>, value: any): void;

classPrivateFieldLooseBase

Base helper for loose mode private fields (smaller bundle size).

/**
 * Loose mode private field base
 * @param receiver - Object to access private field on
 * @param privateKey - Unique key for the private field
 * @returns Receiver object for chaining
 */
function classPrivateFieldLooseBase(receiver: any, privateKey: any): any;

classPrivateFieldLooseKey

Generates unique keys for loose mode private fields.

/**
 * Loose mode private field key
 * @param name - Name of the private field
 * @returns Unique key for loose private field
 */
function classPrivateFieldLooseKey(name: string): string;

Private Method Access

classPrivateMethodGet

Gets a private method from an instance with proper binding.

/**
 * Gets private method
 * @param receiver - Instance containing the private method
 * @param privateSet - WeakSet tracking instances with private methods
 * @param fn - The private method function
 * @returns Bound private method
 */
function classPrivateMethodGet(receiver: any, privateSet: WeakSet<any>, fn: Function): Function;

classPrivateMethodSet

Throws error when attempting to set a private method (read-only).

/**
 * Sets private method (throws error - methods are read-only)
 * @throws TypeError - Private methods are read-only
 */
function classPrivateMethodSet(): never;

classPrivateMethodInitSpec

Initializes private method specifications for a class.

/**
 * Initializes private method specs
 * @param obj - Object to initialize private methods on
 * @param privateSet - WeakSet for tracking method access
 */
function classPrivateMethodInitSpec(obj: any, privateSet: WeakSet<any>): void;

Private Accessor Methods

classPrivateGetter

Accesses private getter methods.

/**
 * Private getter access
 * @param receiver - Instance with private getter
 * @param privateMap - WeakMap containing getter function
 * @returns Result of calling private getter
 */
function classPrivateGetter(receiver: any, privateMap: WeakMap<any, any>): any;

classPrivateSetter

Accesses private setter methods.

/**
 * Private setter access
 * @param receiver - Instance with private setter
 * @param privateMap - WeakMap containing setter function
 * @param value - Value to pass to setter
 */
function classPrivateSetter(receiver: any, privateMap: WeakMap<any, any>, value: any): void;

Static Private Members

classStaticPrivateFieldSpecGet

Gets the value of a static private field.

/**
 * Gets static private field
 * @param receiver - Class constructor
 * @param classConstructor - Expected class constructor
 * @param descriptor - Field descriptor containing value
 * @returns Static private field value
 */
function classStaticPrivateFieldSpecGet(receiver: any, classConstructor: Function, descriptor: any): any;

classStaticPrivateFieldSpecSet

Sets the value of a static private field.

/**
 * Sets static private field
 * @param receiver - Class constructor
 * @param classConstructor - Expected class constructor
 * @param descriptor - Field descriptor to update
 * @param value - Value to set
 * @returns The set value
 */
function classStaticPrivateFieldSpecSet(receiver: any, classConstructor: Function, descriptor: any, value: any): any;

classStaticPrivateFieldDestructureSet

Sets static private field in destructuring context.

/**
 * Static private field destructuring
 * @param receiver - Class constructor
 * @param classConstructor - Expected class constructor  
 * @param descriptor - Field descriptor
 * @param value - Value to set
 * @returns The set value
 */
function classStaticPrivateFieldDestructureSet(receiver: any, classConstructor: Function, descriptor: any, value: any): any;

classStaticPrivateMethodGet

Gets a static private method with proper binding.

/**
 * Gets static private method
 * @param receiver - Class constructor
 * @param classConstructor - Expected class constructor
 * @param method - The static private method
 * @returns The static private method
 */
function classStaticPrivateMethodGet(receiver: any, classConstructor: Function, method: Function): Function;

classStaticPrivateMethodSet

Throws error when attempting to set a static private method.

/**
 * Sets static private method (throws error - methods are read-only)
 * @throws TypeError - Static private methods are read-only
 */
function classStaticPrivateMethodSet(): never;

Private Member Utilities

assertClassBrand

Asserts that an object has the correct class brand for private member access.

/**
 * Asserts class brand for private access
 * @param e - Instance to check
 * @param t - Expected brand/class
 * @param n - Error name (optional)
 * @returns The validated instance
 * @throws TypeError if brand check fails
 */
function assertClassBrand(e: any, t: any, n?: any): any;

checkPrivateRedeclaration

Prevents redeclaration of private members during class definition.

/**
 * Prevents private member redeclaration
 * @param obj - Object being defined
 * @param privateCollection - Collection tracking private members
 * @throws SyntaxError if private member already declared
 */
function checkPrivateRedeclaration(obj: any, privateCollection: WeakSet<any> | WeakMap<any, any>): void;

Access Control Helpers

classCheckPrivateStaticAccess

Checks access permissions for static private members.

/**
 * Checks static private access
 * @param receiver - Object attempting access
 * @param classConstructor - Expected class constructor
 * @throws TypeError if access denied
 */
function classCheckPrivateStaticAccess(receiver: any, classConstructor: Function): void;

classCheckPrivateStaticFieldDescriptor

Validates static private field descriptors.

/**
 * Checks static field descriptor
 * @param descriptor - Field descriptor to validate
 * @param action - Action being performed ('get' or 'set')
 * @returns Validated descriptor
 */
function classCheckPrivateStaticFieldDescriptor(descriptor: any, action: string): any;

classExtractFieldDescriptor

Extracts field descriptors from private field definitions.

/**
 * Extracts field descriptors
 * @param receiver - Object containing field
 * @param privateMap - WeakMap with field data
 * @param action - Action being performed
 * @returns Field descriptor
 */
function classExtractFieldDescriptor(receiver: any, privateMap: WeakMap<any, any>, action: string): any;

Destructuring Support

classPrivateFieldDestructureSet

Sets private field values in destructuring assignments.

/**
 * Sets private field in destructuring
 * @param receiver - Instance to set field on
 * @param privateMap - WeakMap storing field values
 * @param value - Value to destructure and set
 * @returns The set value
 */
function classPrivateFieldDestructureSet(receiver: any, privateMap: WeakMap<any, any>, value: any): any;

Types

// Private field storage
interface PrivateFieldMap extends WeakMap<any, any> {}

// Private method tracking
interface PrivateMethodSet extends WeakSet<any> {}

// Static private field descriptor
interface StaticPrivateFieldDescriptor {
  value: any;
  writable?: boolean;
}

// Private member collections
type PrivateCollection = WeakSet<any> | WeakMap<any, any>;

// Class brand for private access
interface ClassBrand {
  _: void;
}