oxc/npm/oxc-transform
2024-09-08 13:24:58 +08:00
..
scripts chore: use dprint to format js, json and markdown 2024-09-08 13:24:58 +08:00
CHANGELOG.md Release crates v0.26.0 (#5418) 2024-09-03 10:36:02 +08:00
package.json style: add trailing line breaks to package.json files (#5542) 2024-09-06 12:43:44 +00:00
README.md chore: use dprint to format js, json and markdown 2024-09-08 13:24:58 +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>;
}