mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
0fbcf6420b
## Summary - require a string sourceText when sourcemaps are enabled - reject non-string supplied sourceFilename values before map generation - cover invalid and valid source-map option combinations
61 lines
1.3 KiB
TypeScript
61 lines
1.3 KiB
TypeScript
// Printing options and returned output types.
|
|
|
|
/** Standard Source Map v3 output, compatible with Rollup and other JavaScript tooling. */
|
|
export interface SourceMap {
|
|
version: 3;
|
|
mappings: string;
|
|
names: string[];
|
|
sources: string[];
|
|
sourcesContent?: string[];
|
|
}
|
|
|
|
/** Result returned by `printSync`. */
|
|
export interface CodegenResult {
|
|
code: string;
|
|
map: SourceMap | null;
|
|
}
|
|
|
|
/**
|
|
* Code generator options.
|
|
*/
|
|
export interface Options {
|
|
/**
|
|
* String to use for indentation, defaults to `"\t"`.
|
|
* Must be a non-empty string consisting only of spaces and/or tabs.
|
|
* Throws a `TypeError` otherwise.
|
|
*/
|
|
indent?: string;
|
|
|
|
/**
|
|
* Non-negative integer indent level to start from, from `0` to `1000`. Defaults to `0`.
|
|
*/
|
|
startingIndentLevel?: number;
|
|
|
|
/**
|
|
* `.tsx` mode if `true`, in which a lone type parameter prints as `<T,>`.
|
|
* Defaults to `false`.
|
|
*/
|
|
jsx?: boolean;
|
|
|
|
/**
|
|
* `true` if the AST may contain TypeScript syntax (TS-ESLint dialect).
|
|
* Defaults to `false`.
|
|
*/
|
|
ts?: boolean;
|
|
|
|
/**
|
|
* Generate and return a source map in `CodegenResult.map`.
|
|
*/
|
|
sourcemap?: boolean;
|
|
|
|
/**
|
|
* Original source text. Required when `sourcemap` is `true`.
|
|
*/
|
|
sourceText?: string;
|
|
|
|
/**
|
|
* Original source filename recorded in the returned source map.
|
|
*/
|
|
sourceFilename?: string;
|
|
}
|