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

utilities.mddocs/

Utility Helpers

General-purpose utility functions for error handling, property operations, resource management, and other common runtime needs.

Capabilities

Error Handling

_throw

Throws an error (used for expression contexts).

/**
 * Throws an error (used for expression contexts)
 * @param {Error} error - Error to throw
 * @throws {Error} The provided error
 */
function _throw(error): never;

Usage Example:

// In expressions where throw is needed
const value = condition ? validValue : _throw(new Error("Invalid condition"));

_read_only_error

Throws a read-only property error.

/**
 * Throws a read-only property error
 * @param {string} name - Property name
 * @throws {TypeError} Read-only property error
 */
function _read_only_error(name): never;

_write_only_error

Throws a write-only property error.

/**
 * Throws a write-only property error
 * @param {string} name - Property name
 * @throws {TypeError} Write-only property error
 */
function _write_only_error(name): never;

Resource Management

_dispose

Handles resource disposal for using declarations.

/**
 * Handles resource disposal for using declarations
 * @param {Array} stack - Disposal stack
 * @param {Error} error - Current error
 * @param {boolean} hasError - Whether an error occurred
 * @returns {Promise|void} Disposal result
 */
function _dispose(stack, error, hasError): Promise<void> | void;

_using

Creates using declaration contexts.

/**
 * Creates using declaration contexts
 * @param {any} disposable - Disposable resource
 * @param {Array} stack - Disposal stack
 * @param {boolean} isAsync - Whether disposal is async
 * @returns {any} The disposable resource
 */
function _using(disposable, stack, isAsync): any;

_using_ctx

Creates using declaration context objects.

/**
 * Creates using declaration context objects
 * @returns {Object} Using context with disposal stack
 */
function _using_ctx(): Object;

_ts_add_disposable_resource

TypeScript-specific disposable resource handling (re-exported from tslib).

/**
 * TypeScript-specific disposable resource handling (re-exported from tslib.__addDisposableResource)
 * @param {Object} env - Environment object
 * @param {any} value - Disposable value
 * @param {boolean} async - Whether disposal is async
 * @returns {any} The disposable value
 */
function _ts_add_disposable_resource(env, value, async): any;

_ts_dispose_resources

TypeScript-specific resource disposal (re-exported from tslib).

/**
 * TypeScript-specific resource disposal (re-exported from tslib.__disposeResources)
 * @param {Object} env - Environment object with disposal stack
 * @returns {Promise|void} Disposal result
 */
function _ts_dispose_resources(env): Promise<void> | void;

JSX Helpers

_jsx

Creates JSX elements (React elements).

/**
 * Creates JSX elements (React elements)
 * @param {string|Function} type - Element type
 * @param {Object} props - Element properties
 * @param {string|number} key - Element key
 * @param {...any} children - Child elements
 * @returns {Object} React element object
 */
function _jsx(type, props, key, children): Object;

Usage Example:

// For: <div className="container">Hello</div>
const element = _jsx("div", { className: "container" }, undefined, "Hello");

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