interface GeneratorOptions {
    auxiliaryCommentAfter?: string;
    auxiliaryCommentBefore?: string;
    comments?: boolean;
    compact?: boolean | "auto";
    concise?: boolean;
    decoratorsBeforeExport?: boolean;
    filename?: string;
    importAttributesKeyword?: "with" | "assert" | "with-legacy";
    jsescOption?: {
        compact?: boolean;
        es6?: boolean;
        escapeEverything?: boolean;
        indent?: string;
        indentLevel?: number;
        isScriptContext?: boolean;
        json?: boolean;
        lowercaseHex?: boolean;
        minimal?: boolean;
        numbers?: "binary" | "octal" | "decimal" | "hexadecimal";
        quotes?: "single" | "double" | "backtick";
        wrap?: boolean;
    };
    jsonCompatibleStrings?: boolean;
    minified?: boolean;
    retainFunctionParens?: boolean;
    retainLines?: boolean;
    sourceFileName?: string;
    sourceMaps?: boolean;
    sourceRoot?: string;
    shouldPrintComment?(comment): boolean;
}

Properties

auxiliaryCommentAfter?: string

Optional string to add as a block comment at the end of the output file.

auxiliaryCommentBefore?: string

Optional string to add as a block comment at the start of the output file.

comments?: boolean

Should comments be included in output? Defaults to true.

compact?: boolean | "auto"

Set to true to avoid adding whitespace for formatting. Defaults to the value of opts.minified.

concise?: boolean

Set to true to reduce whitespace (but not as much as opts.compact). Defaults to false.

decoratorsBeforeExport?: boolean

Set to true to enable support for experimental decorators syntax before module exports. Defaults to false.

filename?: string

Used in warning messages

importAttributesKeyword?: "with" | "assert" | "with-legacy"

The import attributes/assertions syntax to use. When not specified, @babel/generator will try to match the style in the input code based on the AST shape.

jsescOption?: {
    compact?: boolean;
    es6?: boolean;
    escapeEverything?: boolean;
    indent?: string;
    indentLevel?: number;
    isScriptContext?: boolean;
    json?: boolean;
    lowercaseHex?: boolean;
    minimal?: boolean;
    numbers?: "binary" | "octal" | "decimal" | "hexadecimal";
    quotes?: "single" | "double" | "backtick";
    wrap?: boolean;
}

Options for outputting jsesc representation.

Type declaration

  • Optional compact?: boolean

    The compact option takes a boolean value (true or false), and defaults to true (enabled). When enabled, the output for arrays and objects is as compact as possible; it’s not formatted nicely.

  • Optional es6?: boolean

    The es6 option takes a boolean value (true or false), and defaults to false (disabled). When enabled, any astral Unicode symbols in the input are escaped using ECMAScript 6 Unicode code point escape sequences instead of using separate escape sequences for each surrogate half. If backwards compatibility with ES5 environments is a concern, don’t enable this setting. If the json setting is enabled, the value for the es6 setting is ignored (as if it was false).

  • Optional escapeEverything?: boolean

    The escapeEverything option takes a boolean value (true or false), and defaults to false (disabled). When enabled, all the symbols in the output are escaped — even printable ASCII symbols.

  • Optional indent?: string

    The indent option takes a string value, and defaults to '\t'. When the compact setting is enabled (true), the value of the indent option is used to format the output for arrays and objects.

  • Optional indentLevel?: number

    The indentLevel option takes a numeric value, and defaults to 0. It represents the current indentation level, i.e. the number of times the value of the indent option is repeated.

  • Optional isScriptContext?: boolean

    The isScriptContext option takes a boolean value (true or false), and defaults to false (disabled). When enabled, occurrences of </script and </style in the output are escaped as </script and </style, and <!-- is escaped as \x3C!-- (or \u003C!-- when the json option is enabled). This setting is useful when jsesc’s output ends up as part of a