oxc-transform
TypeScript icon, indicating that this package has built-in type declarations

0.58.1 • Public • Published

Oxc Transform

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

TypeScript and React JSX Transform

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

const { code, declaration, errors } = oxc.transform(
  'test.ts',
  'class A<T> {}',
  {
    typescript: {
      declaration: true, // With isolated declarations in a single step.
    },
  },
);

assert.equal(code, 'class A {}\n');
assert.equal(declaration, 'declare class A<T> {}\n');
assert(errors.length == 0);

Conforms to TypeScript Compiler's --isolated-declaration .d.ts emit.

Usage

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

const { map, code, errors } = oxc.isolatedDeclaration('test.ts', 'class A {}');

assert.equal(code, 'declare class A {}\n');
assert(errors.length == 0);

API

See index.d.ts.

export declare function transform(
  filename: string,
  sourceText: string,
  options?: TransformOptions,
): TransformResult;

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

Readme

Keywords

Package Sidebar

Install

npm i oxc-transform

Homepage

oxc.rs

Weekly Downloads

57,818

Version

0.58.1

License

MIT

Unpacked Size

27 kB

Total Files

6

Last publish

Collaborators

  • boshen