(node: ts.Node)
| 62 | } |
| 63 | |
| 64 | export function getSourceFile(node: ts.Node): ts.SourceFile { |
| 65 | // In certain transformation contexts, `ts.Node.getSourceFile()` can actually return `undefined`, |
| 66 | // despite the type signature not allowing it. In that event, get the `ts.SourceFile` via the |
| 67 | // original node instead (which works). |
| 68 | const directSf = node.getSourceFile() as ts.SourceFile | undefined; |
| 69 | return directSf !== undefined ? directSf : ts.getOriginalNode(node).getSourceFile(); |
| 70 | } |
| 71 | |
| 72 | export function getSourceFileOrNull( |
| 73 | program: ts.Program, |
no test coverage detected