Skip to content

Commit 520d7ff

Browse files
committed
Add depth limit to recursive type reference id generation
4 is the limit.
1 parent c9d081e commit 520d7ff

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9790,7 +9790,7 @@ namespace ts {
97909790
* getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
97919791
* where A.id=111 and number.id=12
97929792
*/
9793-
function getTypeReferenceId(type: TypeReference, typeParameters: Type[]) {
9793+
function getTypeReferenceId(type: TypeReference, typeParameters: Type[], depth = 0) {
97949794
let result = "" + type.target.id;
97959795
for (const t of type.typeArguments) {
97969796
if (isUnconstrainedTypeParameter(t)) {
@@ -9801,8 +9801,8 @@ namespace ts {
98019801
}
98029802
result += "=" + index;
98039803
}
9804-
else if (isTypeReferenceWithGenericArguments(t)) {
9805-
result += "<" + getTypeReferenceId(t, typeParameters) + ">";
9804+
else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
9805+
result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
98069806
}
98079807
else {
98089808
result += "-" + t.id;

0 commit comments

Comments
 (0)