oxc/npm/oxc-transform
2024-09-13 22:51:33 +08:00
..
scripts chore: use dprint to format js, json and markdown 2024-09-08 13:24:58 +08:00
CHANGELOG.md release(oxc): crates v0.28.0 (#5696) 2024-09-11 17:57:55 +08:00
package.json chore: fix package.json EOL 2024-09-13 22:51:33 +08: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>;
}