Skip to content

⬅️ Back to Table of Contents

📄 isSymbolFromDefaultLibrary.ts

📊 Analysis Summary

Metric Count
🔧 Functions 1
📊 Variables & Constants 1

📚 Table of Contents

🛠️ File Location:

📂 packages/type-utils/src/isSymbolFromDefaultLibrary.ts

Variables & Constants

Name Type Kind Value Exported
declarations any const symbol.getDeclarations() ?? []

Functions

isSymbolFromDefaultLibrary(program: ts.Program, symbol: ts.Symbol | undefined): boolean

Code
export function isSymbolFromDefaultLibrary(
  program: ts.Program,
  symbol: ts.Symbol | undefined,
): boolean {
  if (!symbol) {
    return false;
  }

  const declarations = symbol.getDeclarations() ?? [];
  for (const declaration of declarations) {
    const sourceFile = declaration.getSourceFile();
    if (program.isSourceFileDefaultLibrary(sourceFile)) {
      return true;
    }
  }

  return false;
}
  • Parameters:
  • program: ts.Program
  • symbol: ts.Symbol | undefined
  • Return Type: boolean
  • Calls:
  • symbol.getDeclarations
  • declaration.getSourceFile
  • program.isSourceFileDefaultLibrary