MCPcopy Create free account
hub / github.com/angular/angular / getSourceFile

Function getSourceFile

packages/compiler-cli/src/ngtsc/util/src/typescript.ts:64–70  ·  view source on GitHub ↗
(node: ts.Node)

Source from the content-addressed store, hash-verified

62}
63
64export 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
72export function getSourceFileOrNull(
73 program: ts.Program,

Callers 12

recordUsedImportMethod · 0.90
emitMethod · 0.90
emitMethod · 0.90
emitMethod · 0.90
emitMethod · 0.90
constructorMethod · 0.90
resolveMethod · 0.90
resolveMethod · 0.90
detectTraitsMethod · 0.90
nodeDebugInfoFunction · 0.85

Calls 1

getSourceFileMethod · 0.45

Tested by

no test coverage detected