Skip to content

⬅️ Back to Table of Contents

📄 getSourceFileOfNode.ts

📊 Analysis Summary

Metric Count
🔧 Functions 1

📚 Table of Contents

🛠️ File Location:

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

Functions

getSourceFileOfNode(node: ts.Node): ts.SourceFile

Code
export function getSourceFileOfNode(node: ts.Node): ts.SourceFile {
  while (node.kind !== ts.SyntaxKind.SourceFile) {
    node = node.parent;
  }
  return node as ts.SourceFile;
}
  • JSDoc:

    /**
     * Gets the source file for a given node
     */
    

  • Parameters:

  • node: ts.Node
  • Return Type: ts.SourceFile