Skip to content

⬅️ Back to Table of Contents

📄 referenceContainsTypeQuery

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 2

📚 Table of Contents

🛠️ File Location:

📂 packages/eslint-plugin/src/util/referenceContainsTypeQuery.ts

📦 Imports

Name Source
TSESTree @typescript-eslint/utils
AST_NODE_TYPES @typescript-eslint/utils

Functions

referenceContainsTypeQuery(node: TSESTree.Node): boolean

Recursively checks whether a given reference has a type query declaration among its parents

Raw JSDoc
/**
 * Recursively checks whether a given reference has a type query declaration among its parents
 */

Calls:

  • referenceContainsTypeQuery

Internal Comments:

// if we find a different node, there's no chance that we're in a TSTypeQuery

Code
export function referenceContainsTypeQuery(node: TSESTree.Node): boolean {
  switch (node.type) {
    case AST_NODE_TYPES.TSTypeQuery:
      return true;

    case AST_NODE_TYPES.TSQualifiedName:
    case AST_NODE_TYPES.Identifier:
      return referenceContainsTypeQuery(node.parent);

    default:
      // if we find a different node, there's no chance that we're in a TSTypeQuery
      return false;
  }
}

Generated by Syntax Scribe