File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -4487,6 +4487,15 @@ namespace ts {
44874487 }
44884488
44894489 function instantiateAnonymousType(type: ObjectType, mapper: TypeMapper): ObjectType {
4490+ if (mapper.instantiations) {
4491+ let cachedType = mapper.instantiations[type.id];
4492+ if (cachedType) {
4493+ return cachedType;
4494+ }
4495+ }
4496+ else {
4497+ mapper.instantiations = [];
4498+ }
44904499 // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it
44914500 let result = <ResolvedType>createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol);
44924501 result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
@@ -4497,6 +4506,7 @@ namespace ts {
44974506 let numberIndexType = getIndexTypeOfType(type, IndexKind.Number);
44984507 if (stringIndexType) result.stringIndexType = instantiateType(stringIndexType, mapper);
44994508 if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper);
4509+ mapper.instantiations[type.id] = result;
45004510 return result;
45014511 }
45024512
Original file line number Diff line number Diff line change @@ -1953,6 +1953,7 @@ namespace ts {
19531953 /* @internal */
19541954 export interface TypeMapper {
19551955 ( t : TypeParameter ) : Type ;
1956+ instantiations ?: Type [ ] ; // Cache of instantiations created using this type mapper.
19561957 context ?: InferenceContext ; // The inference context this mapper was created from.
19571958 // Only inference mappers have this set (in createInferenceMapper).
19581959 // The identity mapper and regular instantiation mappers do not need it.
You can’t perform that action at this time.
0 commit comments