diff --git a/src/runTsc.js b/src/runTsc.js index 72c0ea4..236a232 100644 --- a/src/runTsc.js +++ b/src/runTsc.js @@ -42,16 +42,17 @@ const runTsc = ({ testPath, config: jestConfig }) => { process.cwd() ); - const options = { - compilerOptions: { - noEmit: true, - ...settings.options, - }, - }; + const options = Object.assign({}, { noEmit: true }, settings.options); + + const program = ts.createProgram([testPath], options); + + const emitResult = program.emit(); - const transpileOutput = ts.transpileModule(testPath, options); + const allDiagnostics = ts + .getPreEmitDiagnostics(program) + .concat(emitResult.diagnostics); - const errors = transpileOutput.diagnostics + const errors = allDiagnostics .map(diagnostic => { if (diagnostic.file) { const {