⬅️ Back to Table of Contents
📄 source-files.ts
📊 Analysis Summary
Metric |
Count |
🔧 Functions |
2 |
📊 Variables & Constants |
1 |
📚 Table of Contents
🛠️ File Location:
📂 packages/typescript-estree/src/source-files.ts
Variables & Constants
Name |
Type |
Kind |
Value |
Exported |
maybeSourceFile |
ts.SourceFile |
const |
code as Partial<ts.SourceFile> |
✗ |
Functions
isSourceFile(code: unknown): 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'
);
}
- Parameters:
code: unknown
- Return Type:
code is ts.SourceFile
getCodeText(code: string | ts.SourceFile): string
Code
export function getCodeText(code: string | ts.SourceFile): string {
return isSourceFile(code) ? code.getFullText(code) : code;
}
- Parameters:
code: string | ts.SourceFile
- Return Type:
string
- Calls:
isSourceFile
code.getFullText