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

Function getFormatDiagnosticsHost

packages/compiler-cli/src/main.ts:182–200  ·  view source on GitHub ↗
(options?: api.CompilerOptions)

Source from the content-addressed store, hash-verified

180}
181
182function getFormatDiagnosticsHost(options?: api.CompilerOptions): ts.FormatDiagnosticsHost {
183 const basePath = options ? options.basePath : undefined;
184 return {
185 getCurrentDirectory: () => basePath || ts.sys.getCurrentDirectory(),
186 // We need to normalize the path separators here because by default, TypeScript
187 // compiler hosts use posix canonical paths. In order to print consistent diagnostics,
188 // we also normalize the paths.
189 getCanonicalFileName: (fileName) => fileName.replace(/\\/g, '/'),
190 getNewLine: () => {
191 // Manually determine the proper new line string based on the passed compiler
192 // options. There is no public TypeScript function that returns the corresponding
193 // new line string. see: https://github.com/Microsoft/TypeScript/issues/29581
194 if (options && options.newLine !== undefined) {
195 return options.newLine === ts.NewLineKind.LineFeed ? '\n' : '\r\n';
196 }
197 return ts.sys.newLine;
198 },
199 };
200}
201
202function reportErrorsAndExit(
203 allDiagnostics: ReadonlyArray<ts.Diagnostic>,

Callers 1

printDiagnosticsFunction · 0.85

Calls 2

getCurrentDirectoryMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…