@types/babel-generator

  • Version 6.25.8
  • Published
  • 5.57 kB
  • 1 dependency
  • MIT license

Install

npm i @types/babel-generator
yarn add @types/babel-generator
pnpm add @types/babel-generator

Overview

TypeScript definitions for babel-generator

Index

Functions

function generate

generate: (
ast: t.Node,
opts?: GeneratorOptions,
code?: string | { [filename: string]: string }
) => GeneratorResult;
  • Turns an AST into code, maintaining sourcemaps, user preferences, and valid output.

    Parameter ast

    the abstract syntax tree from which to generate output code.

    Parameter opts

    used for specifying options for code generation.

    Parameter code

    the original source code, used for source maps.

    Returns

    - an object containing the output code and source map.

Interfaces

interface GeneratorOptions

interface GeneratorOptions {}

    property auxiliaryCommentAfter

    auxiliaryCommentAfter?: string | undefined;
    • Optional string to add as a block comment at the end of the output file.

    property auxiliaryCommentBefore

    auxiliaryCommentBefore?: string | undefined;
    • Optional string to add as a block comment at the start of the output file.

    property comments

    comments?: boolean | undefined;
    • Should comments be included in output? Defaults to true.

    property compact

    compact?: boolean | 'auto' | undefined;
    • Set to true to avoid adding whitespace for formatting. Defaults to the value of opts.minified.

    property concise

    concise?: boolean | undefined;
    • Set to true to reduce whitespace (but not as much as opts.compact). Defaults to false.

    property filename

    filename?: string | undefined;
    • Used in warning messages

    property jsonCompatibleStrings

    jsonCompatibleStrings?: boolean | undefined;
    • Set to true to run jsesc with "json": true to print "\u00A9" vs. "©";

    property minified

    minified?: boolean | undefined;
    • Should the output be minified. Defaults to false.

    property quotes

    quotes?: 'single' | 'double' | undefined;
    • The type of quote to use in the output. If omitted, autodetects based on ast.tokens.

    property retainLines

    retainLines?: boolean | undefined;
    • Attempt to use the same line numbers in the output code as in the source code (helps preserve stack traces). Defaults to false.

    property sourceFileName

    sourceFileName?: string | undefined;
    • The filename for the source code (i.e. the code in the code argument). This will only be used if code is a string.

    property sourceMaps

    sourceMaps?: boolean | undefined;
    • Enable generating source maps. Defaults to false.

    property sourceMapTarget

    sourceMapTarget?: string | undefined;
    • The filename of the generated code that the source map will be associated with.

    property sourceRoot

    sourceRoot?: string | undefined;
    • A root for all relative URLs in the source map.

    method shouldPrintComment

    shouldPrintComment: (comment: string) => boolean;
    • Function that takes a comment (as a string) and returns true if the comment should be included in the output. By default, comments are included if opts.comments is true or if opts.minifed is false and the comment contains @preserve or @license.

    interface GeneratorResult

    interface GeneratorResult {}

      property code

      code: string;

        property map

        map: {};

          Package Files (1)

          Dependencies (1)

          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/babel-generator.

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