Skip to content

⬅️ Back to Table of Contents

📄 referenceContainsTypePredicate

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 2

📚 Table of Contents

🛠️ File Location:

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

📦 Imports

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

Functions

referenceContainsTypePredicate(node: TSESTree.Node): boolean

Recursively checks whether a given reference is used in a type predicate (e.g., arg is string)

Raw JSDoc
/**
 * Recursively checks whether a given reference is used in a type predicate (e.g., `arg is string`)
 */

Calls:

  • referenceContainsTypePredicate
Code
export function referenceContainsTypePredicate(node: TSESTree.Node): boolean {
  switch (node.type) {
    case AST_NODE_TYPES.TSTypePredicate:
      return true;

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

    default:
      return false;
  }
}

Generated by Syntax Scribe