@types/escodegen

  • Version 0.0.10
  • Published
  • 8.56 kB
  • No dependencies
  • MIT license

Install

npm i @types/escodegen
yarn add @types/escodegen
pnpm add @types/escodegen

Overview

TypeScript definitions for escodegen

Index

Functions

function attachComments

attachComments: (ast: any, comments: any, tokens: any) => any;
  • Attaching the comments is needed to keep the comments and to allow blank lines to be preserved.

function generate

generate: (ast: any, options?: GenerateOptions) => string;
  • Produces given Abstract Syntax Tree as javascript code

    Parameter ast

    The Abstract Syntax Tree to generate code from

    Parameter options

    The generation options

Interfaces

interface FormatOptions

interface FormatOptions {}

    property compact

    compact?: boolean | undefined;
    • Do not include superfluous whitespace characters and line terminators. Default is false.

    property escapeless

    escapeless?: boolean | undefined;
    • Escape as few characters in string literals as necessary. Default is false.

    property hexadecimal

    hexadecimal?: boolean | undefined;
    • Generate hexadecimal a numeric literal if it is shorter than its equivalents. Requires option.format.renumber. Default is false.

    property indent

    indent?: IndentOptions | undefined;
    • The indent options

    property json

    json?: boolean | undefined;
    • Enforce JSON format of numeric and string literals. This option takes precedence over option.format.hexadecimal and option.format.quotes. Default is false.

    property newline

    newline?: string | undefined;
    • New line string. Default is '\n'.

    property parentheses

    parentheses?: boolean | undefined;
    • Preserve parentheses in new expressions that have no arguments. Default is true.

    property preserveBlankLines

    preserveBlankLines?: boolean | undefined;

      property quotes

      quotes?: string | undefined;
      • Delimiter to use for string literals. Accepted values are: 'single', 'double', and 'auto'. When 'auto' is specified, escodegen selects a delimiter that results in a shorter literal. Default is 'single'.

      property renumber

      renumber?: boolean | undefined;
      • Try to generate shorter numeric literals than toString() (9.8.1). Default is false.

      property safeConcatenation

      safeConcatenation?: boolean | undefined;

        property semicolons

        semicolons?: boolean | undefined;
        • Preserve semicolons at the end of blocks and programs. Default is true.

        property space

        space?: string | undefined;
        • White space string. Default is standard ' ' (\x20).

        interface GenerateOptions

        interface GenerateOptions {}

          property comment

          comment?: boolean | undefined;
          • If comments are attached to AST, escodegen is going to emit comments to output code. Default is false.

          property directive

          directive?: boolean | undefined;
          • Recognize DirectiveStatement and distinguish it from ExpressionStatement. Default: false

          property file

          file?: string | undefined;
          • If file is provided, it will be used as file property of generated source map.

          property format

          format?: FormatOptions | undefined;
          • The format options

          property moz

          moz?: MozillaOptions | undefined;

            property parse

            parse?: Function | undefined;
            • Mozilla Parser API compatible parse function, e.g., the parse function exported by esprima. If it is provided, generator tries to use the 'raw' representation. See esprima raw information. Default is null.

            property sourceCode

            sourceCode?: string | undefined;

              property sourceContent

              sourceContent?: string | undefined;
              • Optionally option.sourceContent string can be passed (which represents original source of the file, for example it could be a source of coffeescript from which JS is being generated), if provided generated source map will have original source embedded in it.

              property sourceMap

              sourceMap?: string | undefined;
              • sourceMap is the source maps's source filename, that's a name that will show up in the browser debugger for the generated source (if source-maps is enabled). If a non-empty string value is provided, generate a source map.

              property sourceMapRoot

              sourceMapRoot?: string | undefined;
              • Optionally option.sourceMapRoot can be provided, in which case option.sourceMap will be treated as relative to it. For more information about source map itself, see source map library document, V3 draft and HTML5Rocks introduction. Default is undefined sourceMapRoot is the source root for the source map (see the Mozilla documentation). If sourceMapWithCode is truthy, an object is returned from generate() of the form: { code: .. , map: .. }. If file is provided, it will be used as file property of generated source map.

              property sourceMapWithCode

              sourceMapWithCode?: boolean | undefined;
              • . If sourceMapWithCode is true generator returns output hash, where output.map is a source-map representation, which can be serialized as output.map.toString(). output.code is a string with generated JS code (note that it's not going to have //@ sourceMappingURL comment in it).

              property verbatim

              verbatim?: string | undefined;
              • Providing verbatim code generation option to Expression nodes. verbatim option is provided by user as string. When generating Expression code, looking up node[option.verbatim] value and dump it instead of normal code generation.

                Example 1

              interface IndentOptions

              interface IndentOptions {}

                property adjustMultilineComment

                adjustMultilineComment?: boolean | undefined;
                • Adjust the indentation of multiline comments to keep asterisks vertically aligned. Default is false.

                property base

                base?: number | undefined;
                • Base indent level. Default is 0.

                property style

                style?: string | undefined;
                • Indent string. Default is 4 spaces (' ').

                interface MozillaOptions

                interface MozillaOptions {}

                  property comprehensionExpressionStartsWithAssignment

                  comprehensionExpressionStartsWithAssignment?: boolean | undefined;
                  • Default: false

                  property parenthesizedComprehensionBlock

                  parenthesizedComprehensionBlock?: boolean | undefined;
                  • Default: false

                  property starlessGenerator

                  starlessGenerator?: boolean | undefined;
                  • Default: false

                  Enums

                  enum Precedence

                  enum Precedence {
                  Sequence,
                  Yield,
                  Await,
                  Assignment,
                  Conditional,
                  ArrowFunction,
                  LogicalOR,
                  LogicalAND,
                  BitwiseOR,
                  BitwiseXOR,
                  BitwiseAND,
                  Equality,
                  Relational,
                  BitwiseSHIFT,
                  Additive,
                  Multiplicative,
                  Unary,
                  Postfix,
                  Call,
                  New,
                  TaggedTemplate,
                  Member,
                  Primary,
                  }
                  • https://github.com/estools/escodegen/commit/adf113333cd4888cf59bfc4f957df98bf7db82b6

                  member Additive

                  Additive

                    member ArrowFunction

                    ArrowFunction

                      member Assignment

                      Assignment

                        member Await

                        Await

                          member BitwiseAND

                          BitwiseAND

                            member BitwiseOR

                            BitwiseOR

                              member BitwiseSHIFT

                              BitwiseSHIFT

                                member BitwiseXOR

                                BitwiseXOR

                                  member Call

                                  Call

                                    member Conditional

                                    Conditional

                                      member Equality

                                      Equality

                                        member LogicalAND

                                        LogicalAND

                                          member LogicalOR

                                          LogicalOR

                                            member Member

                                            Member

                                              member Multiplicative

                                              Multiplicative

                                                member New

                                                New

                                                  member Postfix

                                                  Postfix

                                                    member Primary

                                                    Primary

                                                      member Relational

                                                      Relational

                                                        member Sequence

                                                        Sequence

                                                          member TaggedTemplate

                                                          TaggedTemplate

                                                            member Unary

                                                            Unary

                                                              member Yield

                                                              Yield

                                                                Package Files (1)

                                                                Dependencies (0)

                                                                No dependencies.

                                                                Dev Dependencies (0)

                                                                No dev dependencies.

                                                                Peer Dependencies (0)

                                                                No peer dependencies.

                                                                Badge

                                                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/escodegen.

                                                                • Markdown
                                                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/escodegen)
                                                                • HTML
                                                                  <a href="https://www.jsdocs.io/package/@types/escodegen"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>