Skip to content

Commit 0ff8eeb

Browse files
committed
Comment getTypeReferenceId and getRelationKey
1 parent 05477e4 commit 0ff8eeb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9774,6 +9774,10 @@ namespace ts {
97749774
return getObjectFlags(type) & ObjectFlags.Reference && some((<TypeReference>type).typeArguments, isUnconstrainedTypeParameter);
97759775
}
97769776

9777+
/**
9778+
* getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
9779+
* where A.id=111 and number.id=12
9780+
*/
97779781
function getTypeReferenceId(type: TypeReference, typeParameters: Type[]) {
97789782
let result = "" + type.target.id;
97799783
for (const t of type.typeArguments) {
@@ -9792,6 +9796,10 @@ namespace ts {
97929796
return result;
97939797
}
97949798

9799+
/**
9800+
* To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters.
9801+
* For other cases, the types ids are used.
9802+
*/
97959803
function getRelationKey(source: Type, target: Type, relation: Map<RelationComparisonResult>) {
97969804
if (relation === identityRelation && source.id > target.id) {
97979805
const temp = source;

0 commit comments

Comments
 (0)