diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6327d204e4b..21633d97a3e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3652,9 +3652,7 @@ module ts { var maybeCache = maybeStack[depth]; // If result is definitely true, copy assumptions to global cache, else copy to next level up var destinationCache = result === Ternary.True || depth === 0 ? relation : maybeStack[depth - 1]; - for (var p in maybeCache) { - destinationCache[p] = maybeCache[p]; - } + copyMap(/*source*/maybeCache, /*target*/destinationCache); } else { // A false result goes straight into global cache (when something is false under assumptions it diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 4ba93729c36..2e5a471bb27 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -208,6 +208,12 @@ module ts { return result; } + export function copyMap(source: Map, target: Map): void { + for (var p in source) { + target[p] = source[p]; + } + } + /** * Creates a map from the elements of an array. *