MCPcopy Index your code
hub / github.com/angular/angular / diagnosticToNode

Function diagnosticToNode

packages/compiler-cli/src/ngtsc/testing/src/utils.ts:169–180  ·  view source on GitHub ↗
(
  diagnostic: ts.Diagnostic | ts.DiagnosticRelatedInformation,
  guard: (node: ts.Node) => node is T,
)

Source from the content-addressed store, hash-verified

167}
168
169export function diagnosticToNode<T extends ts.Node>(
170 diagnostic: ts.Diagnostic | ts.DiagnosticRelatedInformation,
171 guard: (node: ts.Node) => node is T,
172): T {
173 const diag = diagnostic as ts.Diagnostic | ts.DiagnosticRelatedInformation;
174 if (diag.file === undefined) {
175 throw new Error(`Expected ts.Diagnostic to have a file source`);
176 }
177 const node = getTokenAtPosition(diag.file, diag.start!);
178 expect(guard(node)).toBe(true);
179 return node as T;
180}

Callers 2

scope_spec.tsFile · 0.90
standalone_spec.tsFile · 0.90

Calls 2

getTokenAtPositionFunction · 0.90
guardFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…