Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253/** One piece of a streamed input: a string, or a UTF-8 `Uint8Array` decoded as a * stream (so a multi-byte sequence may split across chunks). */export type Chunk = string | Uint8Array;
export interface Options { /** `"erase"` (default): erasable syntax only, every offset preserved. `"downlevel"`: * also down-levels `enum`, instantiated `namespace`, parameter properties, `import =` * and `export =`; lines are preserved, columns only outside converted constructs. */ mode?: "erase" | "downlevel"; /** Parse JSX, with TypeScript's `.tsx` grammar: `<T>x` is JSX, not a cast, and a generic arrow needs `<T,>` * or `<T extends U>`. Erase mode keeps the JSX; downlevel mode writes it for the classic runtime, * `React.createElement(tag, props, ...children)`. Default `false`. */ jsx?: boolean; /** Downlevel mode's JSX element factory, like TypeScript's `jsxFactory`. An `@jsx h` * pragma in a block comment at the top of the file overrides it. Default `"React.createElement"`. */ pragma?: string; /** Downlevel mode's JSX fragment factory, like TypeScript's `jsxFragmentFactory`. An * `@jsxFrag Fragment` pragma in a block comment at the top of the file overrides it. Default `"React.Fragment"`. */ pragmaFrag?: string; /** Receives `{start, end}` (UTF-16 units) for syntax `mode` cannot erase. Without it, * the first such construct throws (or, for a generator, throws from `next()`) an * `UnsupportedSyntaxError`. */ onError?: (error: { start: number; end: number }) => void;}
/** Transforms a whole string, asynchronously. */export function transform(src: string, opts?: Options): Promise<string>;/** Transforms a stream of chunks, asynchronously. Concatenating every yielded string * equals the string-input result for the same total input. */export function transform(src: Iterable<Chunk> | AsyncIterable<Chunk>, opts?: Options): AsyncGenerator<string>;
/** Transforms a whole string, synchronously. */export function transformSync(src: string, opts?: Options): string;/** Transforms a stream of chunks, synchronously. Concatenating every yielded string * equals the string-input result for the same total input. */export function transformSync(src: Iterable<Chunk>, opts?: Options): Generator<string>;
/** Lazily instantiates and returns the first pooled instance of the wasm engine for * `mode`, compiling it at most once per engine. Kept for tests/profiling. */export function engine(mode?: "erase" | "downlevel"): { memory: WebAssembly.Memory; [export_: string]: unknown;};
/** Thrown for syntax the mode cannot erase when no `onError` is given, like Node's * `ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`. */export class UnsupportedSyntaxError extends SyntaxError { code: "ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX"; start: number; end: number; constructor(start: number, end: number);}