CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-swc--helpers

Runtime helper functions for JavaScript and TypeScript transformations performed by the SWC compiler.

Pending
Overview
Eval results
Files

decorators.mddocs/

Decorator Helpers

Support for decorator syntax including method decorators, class decorators, and property decorators.

Capabilities

Core Decorator Functions

_decorate

Applies decorators to class members and classes.

/**
 * Applies decorators to class members and classes
 * @param {Array} decorators - Array of decorator functions
 * @param {Function|Object} target - Target class or prototype
 * @param {string|symbol} key - Property key (for member decorators)
 * @param {Object} desc - Property descriptor
 * @returns {any} Decorated result
 */
function _decorate(decorators, target, key, desc): any;

Usage Example:

// For: @decorator class MyClass {}
_decorate([decorator], MyClass);

// For: @decorator method() {}
_decorate([decorator], MyClass.prototype, "method", descriptor);

_apply_decorated_descriptor

Applies decorated descriptors to object properties.

/**
 * Applies decorated descriptors to object properties
 * @param {Object} target - Target object
 * @param {string|symbol} property - Property key
 * @param {Array} decorators - Array of decorators
 * @param {Object} descriptor - Original property descriptor
 * @param {Object} context - Decorator context
 * @returns {Object} Updated descriptor
 */
function _apply_decorated_descriptor(target, property, decorators, descriptor, context): Object;

Stage 3 Decorator Support

_apply_decs_2203_r

Applies Stage 3 decorators following the 2022-03 revision.

/**
 * Applies Stage 3 decorators following the 2022-03 revision
 * @param {Function} targetClass - Target class
 * @param {Array} memberDecs - Member decorators
 * @param {Array} classDecs - Class decorators
 * @param {Array} classDecsHaveThis - Class decorators with this context
 * @param {number} instanceBrand - Instance brand value
 * @returns {Object} Decorated class information
 */
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, classDecsHaveThis, instanceBrand): Object;

Initializer Helpers

_initializer_define_property

Defines properties using initializer functions.

/**
 * Defines properties using initializer functions
 * @param {Object} target - Target object
 * @param {string|symbol} key - Property key
 * @param {Object} descriptor - Property descriptor
 * @param {Object} context - Definition context
 * @param {Function} initializer - Initializer function
 */
function _initializer_define_property(target, key, descriptor, context, initializer): void;

_initializer_warning_helper

Provides warnings for initializer usage.

/**
 * Provides warnings for initializer usage
 * @param {Object} descriptor - Property descriptor
 * @param {Object} context - Usage context
 * @returns {Function} Warning function
 */
function _initializer_warning_helper(descriptor, context): Function;

Descriptor Utilities

_class_apply_descriptor_get

Applies getter descriptors to class members.

/**
 * Applies getter descriptors to class members
 * @param {Object} target - Target object
 * @param {Object} descriptor - Getter descriptor
 * @returns {any} Getter result
 */
function _class_apply_descriptor_get(target, descriptor): any;

_class_apply_descriptor_set

Applies setter descriptors to class members.

/**
 * Applies setter descriptors to class members
 * @param {Object} target - Target object
 * @param {Object} descriptor - Setter descriptor
 * @param {any} value - Value to set
 * @returns {any} Set value
 */
function _class_apply_descriptor_set(target, descriptor, value): any;

_class_apply_descriptor_update

Applies update descriptors to class members.

/**
 * Applies update descriptors to class members
 * @param {Object} target - Target object
 * @param {Object} descriptor - Update descriptor
 * @param {Function} updateFn - Update function
 * @returns {any} Updated value
 */
function _class_apply_descriptor_update(target, descriptor, updateFn): any;

_class_apply_descriptor_destructure

Applies destructure descriptors to class members.

/**
 * Applies destructure descriptors to class members
 * @param {Object} target - Target object
 * @param {Object} descriptor - Destructure descriptor
 * @returns {any} Destructured value
 */
function _class_apply_descriptor_destructure(target, descriptor): any;

_class_extract_field_descriptor

Extracts field descriptors from class members.

/**
 * Extracts field descriptors from class members
 * @param {Object} target - Target object
 * @param {string|symbol} key - Property key
 * @param {boolean} isStatic - Whether field is static
 * @returns {Object} Field descriptor
 */
function _class_extract_field_descriptor(target, key, isStatic): Object;

TypeScript Decorator Support

_ts_decorate

TypeScript-specific decorator implementation (re-exported from tslib).

/**
 * TypeScript-specific decorator implementation (re-exported from tslib.__decorate)
 * @param {Array} decorators - Array of decorators
 * @param {Function|Object} target - Target class or prototype
 * @param {string|symbol} key - Property key
 * @param {Object} descriptor - Property descriptor
 * @returns {any} Decorated result
 */
function _ts_decorate(decorators, target, key, descriptor): any;

_ts_metadata

Handles TypeScript metadata for decorators (re-exported from tslib).

/**
 * Handles TypeScript metadata for decorators (re-exported from tslib.__metadata)
 * @param {string} metadataKey - Metadata key
 * @param {any} metadataValue - Metadata value
 * @returns {Function} Metadata decorator
 */
function _ts_metadata(metadataKey, metadataValue): Function;

_ts_param

TypeScript parameter decorator helper (re-exported from tslib).

/**
 * TypeScript parameter decorator helper (re-exported from tslib.__param)
 * @param {number} paramIndex - Parameter index
 * @param {Function} decorator - Parameter decorator
 * @returns {Function} Parameter decorator function
 */
function _ts_param(paramIndex, decorator): Function;

Install with Tessl CLI

npx tessl i tessl/npm-swc--helpers

docs

async-generators.md

class-system.md

decorators.md

destructuring.md

index.md

module-interop.md

private-fields.md

type-system.md

utilities.md

tile.json