oxc-transform
Advanced tools
Comparing version 0.30.3 to 0.30.4
@@ -149,7 +149,7 @@ /* auto-generated by NAPI-RS */ | ||
file?: string | ||
mappings?: string | ||
names?: Array<string> | ||
mappings: string | ||
names: Array<string> | ||
sourceRoot?: string | ||
sources?: Array<string | undefined | null> | ||
sourcesContent?: Array<string | undefined | null> | ||
sources: Array<string> | ||
sourcesContent?: Array<string> | ||
version: number | ||
@@ -156,0 +156,0 @@ x_google_ignoreList?: Array<number> |
{ | ||
"name": "oxc-transform", | ||
"version": "0.30.3", | ||
"version": "0.30.4", | ||
"description": "Oxc transform Node API", | ||
@@ -26,11 +26,11 @@ "keywords": [ | ||
"optionalDependencies": { | ||
"@oxc-transform/binding-win32-x64-msvc": "0.30.3", | ||
"@oxc-transform/binding-win32-arm64-msvc": "0.30.3", | ||
"@oxc-transform/binding-linux-x64-gnu": "0.30.3", | ||
"@oxc-transform/binding-linux-arm64-gnu": "0.30.3", | ||
"@oxc-transform/binding-linux-x64-musl": "0.30.3", | ||
"@oxc-transform/binding-linux-arm64-musl": "0.30.3", | ||
"@oxc-transform/binding-darwin-x64": "0.30.3", | ||
"@oxc-transform/binding-darwin-arm64": "0.30.3" | ||
"@oxc-transform/binding-win32-x64-msvc": "0.30.4", | ||
"@oxc-transform/binding-win32-arm64-msvc": "0.30.4", | ||
"@oxc-transform/binding-linux-x64-gnu": "0.30.4", | ||
"@oxc-transform/binding-linux-arm64-gnu": "0.30.4", | ||
"@oxc-transform/binding-linux-x64-musl": "0.30.4", | ||
"@oxc-transform/binding-linux-arm64-musl": "0.30.4", | ||
"@oxc-transform/binding-darwin-x64": "0.30.4", | ||
"@oxc-transform/binding-darwin-arm64": "0.30.4" | ||
} | ||
} |
# Oxc Transform | ||
This is alpha software and may yield incorrect results, feel free to [submit a bug report](https://github.com/oxc-project/oxc/issues/new?assignees=&labels=C-bug&projects=&template=bug_report.md). | ||
## TypeScript and React JSX Transform | ||
```javascript | ||
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); | ||
``` | ||
## [Isolated Declarations for Standalone DTS Emit](https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-beta/#isolated-declarations) | ||
Based on Oxc and conforms to TypeScript Compiler's `--isolated-declaration` `.d.ts` emit. | ||
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](https://github.com/oxc-project/oxc/issues/new?assignees=&labels=C-bug&projects=&template=bug_report.md&title=isolated-declarations:). | ||
### Usage | ||
@@ -15,11 +36,5 @@ | ||
const { map, code, errors } = oxc.isolatedDeclaration('test.ts', 'class A {}', { sourcemap: true }); | ||
const { map, code, errors } = oxc.isolatedDeclaration('test.ts', 'class A {}'); | ||
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); | ||
@@ -30,3 +45,11 @@ ``` | ||
See `index.d.ts`. | ||
```typescript | ||
export declare function transform( | ||
filename: string, | ||
sourceText: string, | ||
options?: TransformOptions, | ||
): TransformResult; | ||
export function isolatedDeclaration( | ||
@@ -37,13 +60,2 @@ filename: string, | ||
): IsolatedDeclarationsResult; | ||
export interface IsolatedDeclarationsOptions { | ||
stripInternal?: boolean; | ||
sourcemap?: boolean; | ||
} | ||
export interface IsolatedDeclarationsResult { | ||
code: string; | ||
map?: SourceMap; | ||
errors: Array<string>; | ||
} | ||
``` |
20854
59