From 0e5b53579ddff988dbc8061a1a24958e2d8b68c7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 1 Dec 2017 14:43:20 -0800 Subject: [PATCH] mappedTypeStack uses a string based on symbols Previously it was a pair of [Type, Symbol]. --- src/compiler/checker.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 329d40e188a..f0cb233cb75 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11127,7 +11127,7 @@ namespace ts { * property is computed by inferring from the source property type to X for the type * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). */ - function inferTypeForHomomorphicMappedType(source: Type, target: MappedType, mappedTypeStack: [Type, Symbol][]): Type { + function inferTypeForHomomorphicMappedType(source: Type, target: MappedType, mappedTypeStack: string[]): Type { const properties = getPropertiesOfType(source); let indexInfo = getIndexInfoOfType(source, IndexKind.String); if (properties.length === 0 && !indexInfo) { @@ -11178,7 +11178,7 @@ namespace ts { return undefined; } - function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0, mappedTypeStack?: [Type, Symbol][]) { + function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0, mappedTypeStack?: string[]) { let symbolStack: Symbol[]; let visited: Map; inferFromTypes(originalSource, originalTarget); @@ -11395,10 +11395,11 @@ namespace ts { // such that direct inferences to T get priority over inferences to Partial, for example. const inference = getInferenceInfoForType((constraintType).type); if (inference && !inference.isFixed) { - if (contains(mappedTypeStack, [source, target.symbol], ([s1, t1], [s2, t2]) => s1 === s2 && t1 === t2)) { + const key = (source.symbol ? getSymbolId(source.symbol) : "no symbol") + "," + getSymbolId(target.symbol); + if (contains(mappedTypeStack, key)) { return; } - (mappedTypeStack || (mappedTypeStack = [])).push([source, target.symbol]); + (mappedTypeStack || (mappedTypeStack = [])).push(key); const inferredType = inferTypeForHomomorphicMappedType(source, target, mappedTypeStack); mappedTypeStack.pop(); if (inferredType) {