Skip to content

⬅️ Back to Table of Contents

📄 source-files

📊 Analysis Summary

Metric Count
🔧 Functions 2

📚 Table of Contents

🛠️ File Location:

📂 packages/typescript-estree/src/source-files.ts

Functions

isSourceFile(code: unknown): code is ts.SourceFile

Parameters:

  • code unknown

Returns: code is ts.SourceFile

Code
export function isSourceFile(code: unknown): code is ts.SourceFile {
  if (typeof code !== 'object' || code == null) {
    return false;
  }

  const maybeSourceFile = code as Partial<ts.SourceFile>;
  return (
    maybeSourceFile.kind === ts.SyntaxKind.SourceFile &&
    typeof maybeSourceFile.getFullText === 'function'
  );
}

getCodeText(code: string | ts.SourceFile): string

Parameters:

  • code string | ts.SourceFile

Returns: string

Calls:

  • isSourceFile
  • code.getFullText
Code
export function getCodeText(code: string | ts.SourceFile): string {
  return isSourceFile(code) ? code.getFullText(code) : code;
}

Generated by Syntax Scribe