diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 3b2eef73860f2..bdd6d4852e853 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -301,7 +301,7 @@ namespace ts { if ((eventName === "change" || eventName === "rename")) { const callbacks = fileWatcherCallbacks.get(fileName); if (callbacks) { - for (const fileCallback of fileWatcherCallbacks.get(fileName)) { + for (const fileCallback of callbacks) { fileCallback(fileName); } } diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 284dbe852d180..4003e8ce78bd2 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -581,7 +581,7 @@ namespace ts { function addExportMemberAssignments(statements: Statement[], name: Identifier): void { const specifiers = !exportEquals && exportSpecifiers && exportSpecifiers.get(name.text); if (specifiers) { - for (const specifier of exportSpecifiers.get(name.text)) { + for (const specifier of specifiers) { statements.push( startOnNewLine( createStatement( @@ -672,7 +672,7 @@ namespace ts { if (specifiers) { const sourceFileId = getOriginalNodeId(currentSourceFile); const bindingNameExportSpecifiers = getOrUpdate(bindingNameExportSpecifiersForFileMap, sourceFileId, () => new StringMap()); - bindingNameExportSpecifiers.set(name.text, exportSpecifiers.get(name.text)); + bindingNameExportSpecifiers.set(name.text, specifiers); addExportMemberAssignments(resultStatements, name); } } @@ -926,7 +926,7 @@ namespace ts { setEmitFlags(transformedUnaryExpression, EmitFlags.NoSubstitution); } let nestedExportAssignment: BinaryExpression; - for (const specifier of bindingNameExportSpecifiersMap.get(operand.text)) { + for (const specifier of bindingNameExportSpecifiers) { nestedExportAssignment = nestedExportAssignment ? createExportAssignment(specifier.name, nestedExportAssignment) : createExportAssignment(specifier.name, transformedUnaryExpression || node); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 96f97e6489b40..53385ca5da3a9 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -700,7 +700,8 @@ namespace FourSlash { const uniqueItems = new ts.StringMap(); for (const item of completions.entries) { if (!ts.setIfNotSet(uniqueItems, item.name, item.kind)) { - assert.equal(item.kind, uniqueItems.get(item.name), `Items should have the same kind, got ${item.kind} and ${uniqueItems.get(item.name)}`); + const uniqueItem = uniqueItems.get(item.name); + assert.equal(item.kind, uniqueItem, `Items should have the same kind, got ${item.kind} and ${uniqueItem}`); } } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 13265b0d5475a..443ebb454d1e1 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -933,10 +933,9 @@ namespace Harness { return undefined; } - if (!libFileNameSourceFileMap.get(fileName)) { - libFileNameSourceFileMap.set(fileName, createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest)); - } - return libFileNameSourceFileMap.get(fileName); + const sourceFile = libFileNameSourceFileMap.get(fileName); + return sourceFile || ts.setAndReturn(libFileNameSourceFileMap, fileName, + createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest)); } export function getDefaultLibFileName(options: ts.CompilerOptions): string { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index ff5d54afc3075..4cf0caed51b94 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1238,40 +1238,43 @@ namespace ts.server { // close existing project and later we'll open a set of configured projects for these files this.closeExternalProject(proj.projectFileName, /*suppressRefresh*/ true); } - else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) { - // this project used to include config files - if (!tsConfigFiles) { - // config files were removed from the project - close existing external project which in turn will close configured projects - this.closeExternalProject(proj.projectFileName, /*suppressRefresh*/ true); - } - else { - // project previously had some config files - compare them with new set of files and close all configured projects that correspond to unused files - const oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName); - let iNew = 0; - let iOld = 0; - while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { - const newConfig = tsConfigFiles[iNew]; - const oldConfig = oldConfigFiles[iOld]; - if (oldConfig < newConfig) { - this.closeConfiguredProject(oldConfig); - iOld++; - } - else if (oldConfig > newConfig) { - iNew++; + else { + const oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName); + if (oldConfigFiles) { + // this project used to include config files + if (!tsConfigFiles) { + // config files were removed from the project - close existing external project which in turn will close configured projects + this.closeExternalProject(proj.projectFileName, /*suppressRefresh*/ true); + } + else { + // project previously had some config files - compare them with new set of files and close all configured projects that correspond to unused files + let iNew = 0; + let iOld = 0; + while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { + const newConfig = tsConfigFiles[iNew]; + const oldConfig = oldConfigFiles[iOld]; + if (oldConfig < newConfig) { + this.closeConfiguredProject(oldConfig); + iOld++; + } + else if (oldConfig > newConfig) { + iNew++; + } + else { + // record existing config files so avoid extra add-refs + (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); + iOld++; + iNew++; + } } - else { - // record existing config files so avoid extra add-refs - (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); - iOld++; - iNew++; + for (let i = iOld; i < oldConfigFiles.length; i++) { + // projects for all remaining old config files should be closed + this.closeConfiguredProject(oldConfigFiles[i]); } } - for (let i = iOld; i < oldConfigFiles.length; i++) { - // projects for all remaining old config files should be closed - this.closeConfiguredProject(oldConfigFiles[i]); - } } } + if (tsConfigFiles) { // store the list of tsconfig files that belong to the external project this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles);