Skip to content
开发文档
API 参考
@swc/wasm-typescript

/# @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

  • 签名:function transform(src: string, options: Options) => Promise<string>

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

  • 签名:function transformSync(src: string, options: Options) => 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
}
Last updated on July 14, 2024