code: function compile(fileNames, options, verbose) {
    const program = ts.createProgram(fileNames, options)
    const emitResult = program.emit()
  
    /* istanbul ignore next */
    if (verbose) {
      const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics)
  
      allDiagnostics.forEach((diagnostic) => {
        if (diagnostic.file) {
          const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(
            diagnostic.start
          )
          const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
          console.log(
            `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`
          )
        } else {
          console.log(`${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`)
        }
      })
    }
  }
docs: Compiler based on code shown in the official docs: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API