From 0f1585f0af48ffdc505ed174e8d0d6d51f0dea16 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Fri, 29 Jul 2016 11:02:33 -0700 Subject: [PATCH 1/2] recreate program if baseUrl or paths changed in tsconfig --- src/services/services.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index ad630fd444e..fd4354923c8 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3097,7 +3097,9 @@ namespace ts { oldSettings.noResolve !== newSettings.noResolve || oldSettings.jsx !== newSettings.jsx || oldSettings.allowJs !== newSettings.allowJs || - oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit); + oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || + oldSettings.baseUrl !== newSettings.baseUrl || + !mapIsEqualTo(oldSettings.paths, newSettings.paths)); // Now create a new compiler const compilerHost: CompilerHost = { From f78b9094be5697d2a14b9e2384c0cc1acfceea47 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Mon, 1 Aug 2016 16:50:16 -0700 Subject: [PATCH 2/2] CR feedback --- src/services/services.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index fd4354923c8..6ec95343e33 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3090,7 +3090,7 @@ namespace ts { const oldSettings = program && program.getCompilerOptions(); const newSettings = hostCache.compilationSettings(); - const changesInCompilationSettingsAffectSyntax = oldSettings && + const shouldCreateNewSourceFiles = oldSettings && (oldSettings.target !== newSettings.target || oldSettings.module !== newSettings.module || oldSettings.moduleResolution !== newSettings.moduleResolution || @@ -3151,7 +3151,7 @@ namespace ts { const oldSourceFiles = program.getSourceFiles(); const oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldSettings); for (const oldSourceFile of oldSourceFiles) { - if (!newProgram.getSourceFile(oldSourceFile.fileName) || changesInCompilationSettingsAffectSyntax) { + if (!newProgram.getSourceFile(oldSourceFile.fileName) || shouldCreateNewSourceFiles) { documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey); } } @@ -3185,7 +3185,7 @@ namespace ts { // Check if the language version has changed since we last created a program; if they are the same, // it is safe to reuse the sourceFiles; if not, then the shape of the AST can change, and the oldSourceFile // can not be reused. we have to dump all syntax trees and create new ones. - if (!changesInCompilationSettingsAffectSyntax) { + if (!shouldCreateNewSourceFiles) { // Check if the old program had this file already const oldSourceFile = program && program.getSourceFileByPath(path); if (oldSourceFile) {