From c77f0c41c29284819f9ef2cc0157d7612ab95d53 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 9 Nov 2018 10:48:28 -0800 Subject: [PATCH] Add affectsModuleResolution to compile options: maxNodeModuleJsDepth Fixes inferred project incorrectly modifying existing compiler options Fixes #27108 --- src/compiler/commandLineParser.ts | 2 +- src/server/project.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 3947ef5184..e3b6fe69d2 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -777,7 +777,7 @@ namespace ts { { name: "maxNodeModuleJsDepth", type: "number", - // TODO: GH#27108 affectsModuleResolution: true, + affectsModuleResolution: true, category: Diagnostics.Advanced_Options, description: Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, diff --git a/src/server/project.ts b/src/server/project.ts index d55c950e1e..7b11f48fbd 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1228,11 +1228,10 @@ namespace ts.server { setCompilerOptions(options?: CompilerOptions) { // Avoid manipulating the given options directly - const newOptions = options ? cloneCompilerOptions(options) : this.getCompilationSettings(); - if (!newOptions) { + if (!options && !this.getCompilationSettings()) { return; } - + const newOptions = cloneCompilerOptions(options || this.getCompilationSettings()); if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") { newOptions.maxNodeModuleJsDepth = 2; }