Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface PrintHandlers

Hierarchy

  • PrintHandlers

Index

Methods

Optional hasGlobalName

  • hasGlobalName(name: string): boolean
  • A hook used by the Printer when generating unique names to avoid collisions with globally defined names that exist outside of the current source file.

    Parameters

    • name: string

    Returns boolean

Optional isEmitNotificationEnabled

  • isEmitNotificationEnabled(node: Node): boolean
  • A hook used to check if an emit notification is required for a node.

    Parameters

    • node: Node

      The node to emit.

    Returns boolean

Optional onEmitNode

  • A hook used by the Printer to provide notifications prior to emitting a node. A compatible implementation must invoke emitCallback with the provided hint and node values.

    example
    var printer = createPrinter(printerOptions, {
      onEmitNode(hint, node, emitCallback) {
        // set up or track state prior to emitting the node...
        emitCallback(hint, node);
        // restore state after emitting the node...
      }
    });
    

    Parameters

    • hint: EmitHint

      A hint indicating the intended purpose of the node.

    • node: Node

      The node to emit.

    • emitCallback: (hint: EmitHint, node: Node) => void

      A callback that, when invoked, will emit the node.

    Returns void

Optional substituteNode

  • A hook used by the Printer to perform just-in-time substitution of a node. This is primarily used by node transformations that need to substitute one node for another, such as replacing myExportedVar with exports.myExportedVar.

    example
    var printer = createPrinter(printerOptions, {
      substituteNode(hint, node) {
        // perform substitution if necessary...
        return node;
      }
    });
    

    Parameters

    • hint: EmitHint

      A hint indicating the intended purpose of the node.

    • node: Node

      The node to emit.

    Returns Node

Generated using TypeDoc