Skip to content

⬅️ Back to Table of Contents

📄 specifierNameMatches

📊 Analysis Summary

Metric Count
🔧 Functions 1

📚 Table of Contents

🛠️ File Location:

📂 packages/type-utils/src/typeOrValueSpecifiers/specifierNameMatches.ts

Functions

specifierNameMatches(type: ts.Type, names: string | string[]): boolean

Parameters:

  • type ts.Type
  • names string | string[]

Returns: boolean

Calls:

  • type.getSymbol
  • names.some
  • candidateNames.includes
Code
export function specifierNameMatches(
  type: ts.Type,
  names: string | string[],
): boolean {
  if (typeof names === 'string') {
    names = [names];
  }

  const symbol = type.aliasSymbol ?? type.getSymbol();
  const candidateNames = symbol
    ? [symbol.escapedName as string, type.intrinsicName]
    : [type.intrinsicName];

  if (names.some(item => candidateNames.includes(item))) {
    return true;
  }

  return false;
}

Generated by Syntax Scribe