Runtime helper functions for JavaScript and TypeScript transformations performed by the SWC compiler.
—
Runtime implementation of private class fields and methods, providing encapsulation features for classes.
Gets the value of a private instance field.
/**
* Gets the value of a private instance field
* @param {Object} receiver - The instance containing the private field
* @param {WeakMap} privateMap - WeakMap storing private field values
* @returns {any} The private field value
* @throws {TypeError} If private field not found
*/
function _class_private_field_get(receiver, privateMap): any;Usage Example:
// For a private field #value
const privateValue = _class_private_field_get(this, _value);Sets the value of a private instance field.
/**
* Sets the value of a private instance field
* @param {Object} receiver - The instance containing the private field
* @param {WeakMap} privateMap - WeakMap storing private field values
* @param {any} value - Value to set
* @returns {any} The set value
*/
function _class_private_field_set(receiver, privateMap, value): any;Initializes a private instance field.
/**
* Initializes a private instance field
* @param {Object} obj - The instance to initialize
* @param {WeakMap} privateMap - WeakMap to store the private field
* @param {any} value - Initial value
*/
function _class_private_field_init(obj, privateMap, value): void;Updates a private instance field with an operation.
/**
* Updates a private instance field with an operation
* @param {Object} receiver - The instance containing the private field
* @param {WeakMap} privateMap - WeakMap storing private field values
* @param {Function} updateFn - Update function
* @returns {any} The updated value
*/
function _class_private_field_update(receiver, privateMap, updateFn): any;Handles destructuring of private fields.
/**
* Handles destructuring of private fields
* @param {Object} receiver - The instance containing the private field
* @param {WeakMap} privateMap - WeakMap storing private field values
* @returns {any} The private field value for destructuring
*/
function _class_private_field_destructure(receiver, privateMap): any;Gets a private instance method.
/**
* Gets a private instance method
* @param {Object} receiver - The instance containing the private method
* @param {WeakSet} privateSet - WeakSet tracking private method access
* @param {Function} fn - The private method function
* @returns {Function} The private method bound to receiver
*/
function _class_private_method_get(receiver, privateSet, fn): Function;Initializes a private instance method.
/**
* Initializes a private instance method
* @param {Object} obj - The instance to initialize
* @param {WeakSet} privateSet - WeakSet to track private method access
*/
function _class_private_method_init(obj, privateSet): void;Throws error when attempting to set a private method (read-only).
/**
* Throws error when attempting to set a private method
* @throws {TypeError} Private methods are read-only
*/
function _class_private_method_set(): never;Gets the value of a private static field.
/**
* Gets the value of a private static field
* @param {Object} receiver - The class or instance
* @param {Function} classConstructor - The class constructor
* @param {Object} descriptor - Private field descriptor
* @returns {any} The private static field value
*/
function _class_static_private_field_spec_get(receiver, classConstructor, descriptor): any;Sets the value of a private static field.
/**
* Sets the value of a private static field
* @param {Object} receiver - The class or instance
* @param {Function} classConstructor - The class constructor
* @param {Object} descriptor - Private field descriptor
* @param {any} value - Value to set
* @returns {any} The set value
*/
function _class_static_private_field_spec_set(receiver, classConstructor, descriptor, value): any;Updates a private static field with an operation.
/**
* Updates a private static field with an operation
* @param {Object} receiver - The class or instance
* @param {Function} classConstructor - The class constructor
* @param {Object} descriptor - Private field descriptor
* @param {Function} updateFn - Update function
* @returns {any} The updated value
*/
function _class_static_private_field_update(receiver, classConstructor, descriptor, updateFn): any;Handles destructuring of private static fields.
/**
* Handles destructuring of private static fields
* @param {Object} receiver - The class or instance
* @param {Function} classConstructor - The class constructor
* @param {Object} descriptor - Private field descriptor
* @returns {any} The private static field value for destructuring
*/
function _class_static_private_field_destructure(receiver, classConstructor, descriptor): any;Gets a private static method.
/**
* Gets a private static method
* @param {Object} receiver - The class or instance
* @param {Function} classConstructor - The class constructor
* @param {Function} method - The private static method
* @returns {Function} The private static method
*/
function _class_static_private_method_get(receiver, classConstructor, method): Function;Checks access to private static members.
/**
* Checks access to private static members
* @param {Object} receiver - The receiver object
* @param {Function} classConstructor - The class constructor
* @throws {TypeError} If access is invalid
*/
function _class_check_private_static_access(receiver, classConstructor): void;Checks private static field descriptor validity.
/**
* Checks private static field descriptor validity
* @param {Object} descriptor - Field descriptor to check
* @param {string} action - Action being performed
* @throws {TypeError} If descriptor is invalid for action
*/
function _class_check_private_static_field_descriptor(descriptor, action): void;Checks for private field redeclaration errors.
/**
* Checks for private field redeclaration errors
* @param {Object} obj - Object being checked
* @param {WeakMap|WeakSet} privateCollection - Private field collection
* @throws {SyntaxError} If private field already declared
*/
function _check_private_redeclaration(obj, privateCollection): void;Gets the base object for loose mode private field access.
/**
* Gets the base object for loose mode private field access
* @param {Object} receiver - The receiver object
* @param {Object} privateKey - Private field key
* @returns {Object} Base object for private field access
*/
function _class_private_field_loose_base(receiver, privateKey): Object;Gets the key for loose mode private field access.
/**
* Gets the key for loose mode private field access
* @param {string} name - Private field name
* @returns {string} Mangled private field key
*/
function _class_private_field_loose_key(name): string;Install with Tessl CLI
npx tessl i tessl/npm-swc--helpers