oxc/npm/oxc-transform
2024-08-25 13:32:47 +08:00
..
scripts fix(npm): libc field should not be null 2024-08-22 23:29:22 +08:00
CHANGELOG.md Release crates v0.25.0 (#5107) 2024-08-23 15:37:36 +08:00
package.json Release crates v0.25.0 (#5107) 2024-08-23 15:37:36 +08:00
README.md feat(isolated_declaration): support sourcemap option (#5170) 2024-08-25 13:32:47 +08:00

Oxc Transform

Isolated Declarations for Standalone DTS Emit

Based on Oxc and conforms to TypeScript Compiler's --isolated-declaration .d.ts emit.

This is still in alpha and may yield incorrect results, feel free to submit a bug report.

Usage

import assert from 'assert';
import oxc from 'oxc-transform';

const { sourceMap, sourceText, errors } = oxc.isolatedDeclaration("test.ts", "class A {}", { sourcemap: true });

assert.equal(sourceText, "declare class A {}\n");
assert.deepEqual(ret.sourceMap, {
  mappings: "AAAA,cAAM,EAAE,CAAE",
  names: [],
  sources: ["test.ts"],
  sourcesContent: ["class A {}"],
});
assert(errors.length == 0);

API

export function isolatedDeclaration(filename: string, sourceText: string, options: IsolatedDeclarationsOptions): IsolatedDeclarationsResult

export interface IsolatedDeclarationsOptions {
  sourcemap: boolean
}

export interface IsolatedDeclarationsResult {
  sourceText: string
  errors: Array<string>
}