MCPcopy Create free account
hub / github.com/cure53/DOMPurify / compile

Function compile

typescript/verify.js:106–133  ·  view source on GitHub ↗

* Compiles a TypeScript project. * @param {typeof ts} compiler The TypeScript compiler to use. * @param {string} configFileName The file name of the TypeScript config file. * @returns {Promise } The diagnostics produced.

(compiler, configFileName)

Source from the content-addressed store, hash-verified

104 * @returns {Promise<ts.Diagnostic[]>} The diagnostics produced.
105 */
106async function compile(compiler, configFileName) {
107 let jsonParseResult = compiler.parseConfigFileTextToJson(
108 configFileName,
109 await fs.readFile(configFileName, { encoding: 'utf8' })
110 );
111
112 if (!jsonParseResult.config && jsonParseResult.error) {
113 return [jsonParseResult.error];
114 }
115
116 let config = compiler.parseJsonConfigFileContent(
117 jsonParseResult.config,
118 compiler.sys,
119 path.dirname(configFileName)
120 );
121 if (config.errors.length > 0) {
122 return config.errors;
123 }
124
125 let program = compiler.createProgram(config.fileNames, config.options);
126 let emitResult = program.emit(
127 undefined,
128 // Do not emit anything.
129 () => undefined
130 );
131
132 return compiler.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
133}
134
135/**
136 * Prints the diagnostics to stdout.

Callers 1

verifyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected