Skip to content

Commit

Permalink
fix(napi/transform): update napi files
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Aug 6, 2024
1 parent bc611d7 commit 01d85de
Show file tree
Hide file tree
Showing 2 changed files with 397 additions and 341 deletions.
121 changes: 64 additions & 57 deletions napi/transform/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
/* tslint:disable */
/* eslint-disable */

/* auto-generated by NAPI-RS */

export interface TypeScriptBindingOptions {
jsxPragma?: string
jsxPragmaFrag?: string
onlyRemoveTypeImports?: boolean
allowNamespaces?: boolean
allowDeclareFields?: boolean
/* eslint-disable */
export interface ArrowFunctionsBindingOptions {
/**
* Also generate a `.d.ts` declaration file for TypeScript files.
*
* The source file must be compliant with all
* [`isolatedDeclarations`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations)
* requirements.
* This option enables the following:
* * Wrap the generated function in .bind(this) and keeps uses of this inside the function as-is, instead of using a renamed this.
* * Add a runtime check to ensure the functions are not instantiated.
* * Add names to arrow functions.
*
* @default false
*/
declaration?: boolean
spec?: boolean
}

export interface Es2015BindingOptions {
/** Transform arrow functions into function expressions. */
arrowFunction?: ArrowFunctionsBindingOptions
}

/** TypeScript Isolated Declarations for Standalone DTS Emit */
export declare function isolatedDeclaration(filename: string, sourceText: string): IsolatedDeclarationsResult

export interface IsolatedDeclarationsResult {
sourceText: string
errors: Array<string>
}

/**
* Configure how TSX and JSX are transformed.
*
Expand Down Expand Up @@ -104,21 +109,30 @@ export interface ReactBindingOptions {
*/
useSpread?: boolean
}
export interface ArrowFunctionsBindingOptions {
/**
* This option enables the following:
* * Wrap the generated function in .bind(this) and keeps uses of this inside the function as-is, instead of using a renamed this.
* * Add a runtime check to ensure the functions are not instantiated.
* * Add names to arrow functions.
*
* @default false
*/
spec?: boolean
}
export interface Es2015BindingOptions {
/** Transform arrow functions into function expressions. */
arrowFunction?: ArrowFunctionsBindingOptions

export interface SourceMap {
file?: string
mappings?: string
sourceRoot?: string
sources?: Array<string | undefined | null>
sourcesContent?: Array<string | undefined | null>
names?: Array<string>
}

/**
* Transpile a JavaScript or TypeScript into a target ECMAScript version.
*
* @param filename The name of the file being transformed. If this is a
* relative path, consider setting the {@link TransformOptions#cwd} option..
* @param sourceText the source code itself
* @param options The options for the transformation. See {@link
* TransformOptions} for more information.
*
* @returns an object containing the transformed code, source maps, and any
* errors that occurred during parsing or transformation.
*/
export declare function transform(filename: string, sourceText: string, options?: TransformOptions | undefined | null): TransformResult

/**
* Options for transforming a JavaScript or TypeScript file.
*
Expand Down Expand Up @@ -154,20 +168,7 @@ export interface TransformOptions {
*/
sourcemap?: boolean
}
export interface SourceMap {
file?: string
mappings?: string
sourceRoot?: string
sources?: Array<string | undefined | null>
sourcesContent?: Array<string | undefined | null>
names?: Array<string>
}
export interface IsolatedDeclarationsResult {
sourceText: string
errors: Array<string>
}
/** TypeScript Isolated Declarations for Standalone DTS Emit */
declare function isolatedDeclaration(filename: string, sourceText: string): IsolatedDeclarationsResult

export interface TransformResult {
/**
* The transformed code.
Expand Down Expand Up @@ -207,16 +208,22 @@ export interface TransformResult {
*/
errors: Array<string>
}
/**
* Transpile a JavaScript or TypeScript into a target ECMAScript version.
*
* @param filename The name of the file being transformed. If this is a
* relative path, consider setting the {@link TransformOptions#cwd} option..
* @param sourceText the source code itself
* @param options The options for the transformation. See {@link
* TransformOptions} for more information.
*
* @returns an object containing the transformed code, source maps, and any
* errors that occurred during parsing or transformation.
*/
declare function transform(filename: string, sourceText: string, options?: TransformOptions | undefined | null): TransformResult

export interface TypeScriptBindingOptions {
jsxPragma?: string
jsxPragmaFrag?: string
onlyRemoveTypeImports?: boolean
allowNamespaces?: boolean
allowDeclareFields?: boolean
/**
* Also generate a `.d.ts` declaration file for TypeScript files.
*
* The source file must be compliant with all
* [`isolatedDeclarations`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations)
* requirements.
*
* @default false
*/
declaration?: boolean
}

Loading

0 comments on commit 01d85de

Please sign in to comment.