oxc/npm/oxc-transform
oxc-bot d56264ee9a
release(crates): v0.30.3 (#6104)
## [0.30.3] - 2024-09-27

### Bug Fixes

- a8338dd isolated-declarations: Accidentally collected references of
original ast (#6102) (Dunqing)
- 933a743 semantic: Add interfaces and functions to
`SymbolFlags::ClassExcludes` (#6057) (DonIsaac)

### Documentation

- 6167f29 oxc-transform: Modify the example code in the `Readme` file
(#6103) (loong.woo)

---------

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-27 14:23:48 +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.30.3 (#6104) 2024-09-27 14:23:48 +08:00
package.json release(crates): v0.30.3 (#6104) 2024-09-27 14:23:48 +08:00
README.md release(crates): v0.30.3 (#6104) 2024-09-27 14:23:48 +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 { map, code, errors } = oxc.isolatedDeclaration('test.ts', 'class A {}', { sourcemap: true });

assert.equal(code, 'declare class A {}\n');
assert.deepEqual(map, {
  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 {
  stripInternal?: boolean;
  sourcemap?: boolean;
}

export interface IsolatedDeclarationsResult {
  code: string;
  map?: SourceMap;
  errors: Array<string>;
}