Skip to content

Commit f30931c

Browse files
committed
Comment getTypeReferenceId and getRelationKey
1 parent 7a94913 commit f30931c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/compiler/checker.ts

+8
Original file line numberDiff line numberDiff line change
@@ -9779,6 +9779,10 @@ namespace ts {
97799779
return getObjectFlags(type) & ObjectFlags.Reference && some((<TypeReference>type).typeArguments, isUnconstrainedTypeParameter);
97809780
}
97819781

9782+
/**
9783+
* getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
9784+
* where A.id=111 and number.id=12
9785+
*/
97829786
function getTypeReferenceId(type: TypeReference, typeParameters: Type[]) {
97839787
let result = "" + type.target.id;
97849788
for (const t of type.typeArguments) {
@@ -9797,6 +9801,10 @@ namespace ts {
97979801
return result;
97989802
}
97999803

9804+
/**
9805+
* To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters.
9806+
* For other cases, the types ids are used.
9807+
*/
98009808
function getRelationKey(source: Type, target: Type, relation: Map<RelationComparisonResult>) {
98019809
if (relation === identityRelation && source.id > target.id) {
98029810
const temp = source;

0 commit comments

Comments
 (0)