| Crates.io | oxc_transform_napi |
| lib.rs | oxc_transform_napi |
| version | 0.110.0 |
| created_at | 2024-06-30 12:04:03.606061+00 |
| updated_at | 2026-01-19 13:47:54.216998+00 |
| description | A collection of JavaScript tools written in Rust. |
| homepage | https://oxc.rs |
| repository | https://github.com/oxc-project/oxc |
| max_upload_size | |
| id | 1287949 |
| size | 87,495 |
import assert from "assert";
import { transformSync } from "oxc-transform";
const { code, declaration, errors } = transformSync("test.ts", "class A<T> {}", {
typescript: {
declaration: true, // With isolated declarations in a single step.
},
});
// or `await transform(filename, code, options)`
assert.equal(code, "class A {}\n");
assert.equal(declaration, "declare class A<T> {}\n");
assert(errors.length == 0);
Conforms to TypeScript compiler's --isolatedDeclarations .d.ts emit.
import assert from "assert";
import { isolatedDeclarationSync } from "oxc-transform";
const { map, code, errors } = isolatedDeclarationSync("test.ts", "class A {}");
// or `await isolatedDeclaration(filename, code, options)`
assert.equal(code, "declare class A {}\n");
assert(errors.length == 0);
// Synchronous transform
transformSync(
filename: string,
sourceText: string,
options?: TransformOptions,
): TransformResult
// Asynchronous transform
transform(
filename: string,
sourceText: string,
options?: TransformOptions,
): Promise<TransformResult>
// Synchronous isolated declaration
isolatedDeclarationSync(
filename: string,
sourceText: string,
options?: IsolatedDeclarationsOptions,
): IsolatedDeclarationsResult
// Asynchronous isolated declaration
isolatedDeclaration(
filename: string,
sourceText: string,
options?: IsolatedDeclarationsOptions,
): Promise<IsolatedDeclarationsResult>
Use the Sync versions for synchronous operations. Use async versions for asynchronous operations, which can be beneficial in I/O-bound or concurrent scenarios, though they add async overhead.
See index.d.ts for complete type definitions.
See https://stackblitz.com/edit/oxc-transform for usage example.