@arcmantle/lit-jsx
    Preparing search index...

    Contains utility methods for retrieving and manipulating node paths in Babel ASTs.

    Index

    Constructors

    Methods

    • Parameters

      • tagName: string
      • variableName: string
      • path: NodePath
      • program: Program

      Returns Identifier

    • Parameters

      • path: NodePath
      • tagName: string
      • variableName: string
      • createDeclaration: () => VariableDeclarator

      Returns Identifier

    • Finds the closest arrow function expression with an expression body starting from the given path. Returns the NodePath of the arrow function expression if found, otherwise undefined.

      Parameters

      • path: NodePath

      Returns undefined | NodePath<ArrowFunctionExpression>

    • Parameters

      • importSource: (value: string) => boolean
      • importName: (value: string) => boolean
      • createImport: () => ImportDeclaration
      • program: Program
      • path: NodePath

      Returns void

    • Hoists the expression to a variable declaration in the closest scope.

      If the path is inside an arrow function with an expression body, it converts the arrow function body to a block statement and inserts the variable declaration before the return statement.

      If the path is not inside such an arrow function, it inserts the variable declaration before the closest statement and replaces the target node with the new variable identifier.

      Parameters

      • path: NodePath
      • variableName: string
      • expression: Expression
      • expandArrow: boolean = true

      Returns Identifier