mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
cd25e4f56e
## Summary Make Codegen conformance failures visible when the Rust reference panics. - Preserve `null` for source text with parser diagnostics. - Return a N-API error for a caught reference panic. - Let Vitest fail the affected fixture instead of silently skipping it.
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
/* auto-generated by NAPI-RS */
|
|
/* eslint-disable */
|
|
/**
|
|
* Parse `source_text` with `oxc_parser` and print the AST with `oxc_codegen`.
|
|
*
|
|
* Returns `null` if the source text could not be parsed without errors, which tells the caller
|
|
* there is nothing to compare for this fixture.
|
|
*
|
|
* Comments are not printed. `oxc-codegen` does not print comments, and the ESTree AST the JS side
|
|
* works from carries no comment data anyway.
|
|
*
|
|
* # Errors
|
|
*
|
|
* Returns any panics as errors to avoid aborting the whole Node process.
|
|
*/
|
|
export declare function codegen(filename: string, sourceText: string, options?: Options | undefined | null): string | null
|
|
|
|
/**
|
|
* Options describing how a fixture should be parsed.
|
|
*
|
|
* These are the same options the JS side passes to `oxc-parser`, so that both sides parse
|
|
* the fixture identically.
|
|
*/
|
|
export interface Options {
|
|
/** `"js"`, `"jsx"`, `"ts"` or `"tsx"`. When absent, the language comes from the filename. */
|
|
lang?: string
|
|
/** `"script"`, `"module"` or `"unambiguous"`. When absent, it comes from the language. */
|
|
sourceType?: string
|
|
/**
|
|
* Whether to keep the `ParenthesizedExpression` / `TSParenthesizedType` wrapper nodes.
|
|
* Default `false`.
|
|
*/
|
|
preserveParens?: boolean
|
|
}
|
|
export interface Comment {
|
|
type: 'Line' | 'Block'
|
|
value: string
|
|
start: number
|
|
end: number
|
|
}
|
|
|
|
export interface ErrorLabel {
|
|
message: string | null
|
|
start: number
|
|
end: number
|
|
}
|
|
|
|
export interface OxcError {
|
|
severity: Severity
|
|
message: string
|
|
labels: Array<ErrorLabel>
|
|
helpMessage: string | null
|
|
codeframe: string | null
|
|
}
|
|
|
|
export declare const enum Severity {
|
|
Error = 'Error',
|
|
Warning = 'Warning',
|
|
Advice = 'Advice'
|
|
}
|