mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
58f7ab9c1d
Follow-on after #25585. Pure style change. I hate the way LLMs put line breaks in weird places like after "the" - it makes comments hard to read. And what's with all the colons and semicolons? No substantive changes, just reformatting comments and docs to avoid this unreadable formatting.
79 lines
2.1 KiB
TypeScript
79 lines
2.1 KiB
TypeScript
/* auto-generated by NAPI-RS */
|
|
/* eslint-disable */
|
|
/**
|
|
* Parse `source_text` with `oxc_parser` and print the AST with `oxc_codegen`, including a source map.
|
|
*
|
|
* 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): CodegenResult | null
|
|
|
|
/** Generated code and its source mappings. */
|
|
export interface CodegenResult {
|
|
/** Generated source text. */
|
|
code: string
|
|
/** Source map generated by `oxc_codegen`. */
|
|
map: SourceMap
|
|
}
|
|
|
|
/**
|
|
* 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'
|
|
}
|
|
export interface SourceMap {
|
|
file?: string
|
|
mappings: string
|
|
names: Array<string>
|
|
sourceRoot?: string
|
|
sources: Array<string>
|
|
sourcesContent?: Array<string>
|
|
version: number
|
|
x_google_ignoreList?: Array<number>
|
|
}
|