From 5cf202ead1aeca4beaddf3a73d562173087b20de Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Mon, 4 Jun 2018 13:45:52 -0400 Subject: [PATCH] Avoid an infinite loop when requesting compiler options --- lib/incremental-typescript-compiler/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/incremental-typescript-compiler/index.js b/lib/incremental-typescript-compiler/index.js index a9dc7b63f..1ea85bcab 100644 --- a/lib/incremental-typescript-compiler/index.js +++ b/lib/incremental-typescript-compiler/index.js @@ -29,6 +29,7 @@ module.exports = class IncrementalTypescriptCompiler { this._ts = project.require('typescript'); this._watchProgram = null; + this._compilerOptions = null; } treeForHost() { @@ -115,6 +116,10 @@ module.exports = class IncrementalTypescriptCompiler { } } }); + + // Prefetch the compiler options, because fetching them while reporting a diagnostic + // can result in a diagnostic-reporting loop in certain states + this._compilerOptions = this.getProgram().getCompilerOptions(); } getProgram() { @@ -130,8 +135,7 @@ module.exports = class IncrementalTypescriptCompiler { } _shouldFailOnTypeError() { - let options = this.getProgram().getCompilerOptions(); - return !!options.noEmitOnError; + return !!this._compilerOptions.noEmitOnError; } _mirageDirectory() {