MCPcopy Index your code
hub / github.com/rollup/plugins / createFormattingHost

Function createFormattingHost

packages/typescript/src/diagnostics/host.ts:15–39  ·  view source on GitHub ↗
(
  ts: typeof typescript,
  compilerOptions: CompilerOptions
)

Source from the content-addressed store, hash-verified

13 * @see https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API
14 */
15export default function createFormattingHost(
16 ts: typeof typescript,
17 compilerOptions: CompilerOptions
18): DiagnosticsHost {
19 return {
20 /** Returns the compiler options for the project. */
21 getCompilationSettings: () => compilerOptions,
22 /** Returns the current working directory. */
23 getCurrentDirectory: () => process.cwd(),
24 /** Returns the string that corresponds with the selected `NewLineKind`. */
25 getNewLine() {
26 switch (compilerOptions.newLine) {
27 case ts.NewLineKind.CarriageReturnLineFeed:
28 return '\r\n';
29 case ts.NewLineKind.LineFeed:
30 return '\n';
31 default:
32 return ts.sys.newLine;
33 }
34 },
35 /** Returns a lower case name on case insensitive systems, otherwise the original name. */
36 getCanonicalFileName: (fileName) =>
37 ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase()
38 };
39}

Callers 1

typescriptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected