@swc/wasm-typescript

Installation

npm install @swc/wasm-typescript

Usage

import { transform } from '@swc/wasm-typescript';

const tsSourceCode = `
export function add(a: number, b: number) {
    return a + b;
}
`;

const code = await transform(tsSourceCode, {

})

APIs

transform, transformSync

  • Signature: function transform(src: string, options: Options) => Promise<string>
  • Signature: function transformSync(src: string, options: Options) => string

Types

type Options = {
    // Defaults to 'unknown', which automatically detects the module type.
    module?: boolean | 'unknown'

    filename?: string;

    parser?: TsSyntax
}