Skip to content

Commit 0e5b535

Browse files
committed
mappedTypeStack uses a string based on symbols
Previously it was a pair of [Type, Symbol].
1 parent c7d53f8 commit 0e5b535

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/compiler/checker.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11127,7 +11127,7 @@ namespace ts {
1112711127
* property is computed by inferring from the source property type to X for the type
1112811128
* variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for).
1112911129
*/
11130-
function inferTypeForHomomorphicMappedType(source: Type, target: MappedType, mappedTypeStack: [Type, Symbol][]): Type {
11130+
function inferTypeForHomomorphicMappedType(source: Type, target: MappedType, mappedTypeStack: string[]): Type {
1113111131
const properties = getPropertiesOfType(source);
1113211132
let indexInfo = getIndexInfoOfType(source, IndexKind.String);
1113311133
if (properties.length === 0 && !indexInfo) {
@@ -11178,7 +11178,7 @@ namespace ts {
1117811178
return undefined;
1117911179
}
1118011180

11181-
function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0, mappedTypeStack?: [Type, Symbol][]) {
11181+
function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0, mappedTypeStack?: string[]) {
1118211182
let symbolStack: Symbol[];
1118311183
let visited: Map<boolean>;
1118411184
inferFromTypes(originalSource, originalTarget);
@@ -11395,10 +11395,11 @@ namespace ts {
1139511395
// such that direct inferences to T get priority over inferences to Partial<T>, for example.
1139611396
const inference = getInferenceInfoForType((<IndexType>constraintType).type);
1139711397
if (inference && !inference.isFixed) {
11398-
if (contains(mappedTypeStack, [source, target.symbol], ([s1, t1], [s2, t2]) => s1 === s2 && t1 === t2)) {
11398+
const key = (source.symbol ? getSymbolId(source.symbol) : "no symbol") + "," + getSymbolId(target.symbol);
11399+
if (contains(mappedTypeStack, key)) {
1139911400
return;
1140011401
}
11401-
(mappedTypeStack || (mappedTypeStack = [])).push([source, target.symbol]);
11402+
(mappedTypeStack || (mappedTypeStack = [])).push(key);
1140211403
const inferredType = inferTypeForHomomorphicMappedType(source, <MappedType>target, mappedTypeStack);
1140311404
mappedTypeStack.pop();
1140411405
if (inferredType) {

0 commit comments

Comments
 (0)