Skip to content

Commit 07d850c

Browse files
authored
Prevent type parameter printing from recuring on the same symbol (#31453)
1 parent 9052804 commit 07d850c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/compiler/checker.ts

+6
Original file line numberDiff line numberDiff line change
@@ -4302,6 +4302,11 @@ namespace ts {
43024302
function lookupTypeParameterNodes(chain: Symbol[], index: number, context: NodeBuilderContext) {
43034303
Debug.assert(chain && 0 <= index && index < chain.length);
43044304
const symbol = chain[index];
4305+
const symbolId = "" + getSymbolId(symbol);
4306+
if (context.typeParameterSymbolList && context.typeParameterSymbolList.get(symbolId)) {
4307+
return undefined;
4308+
}
4309+
(context.typeParameterSymbolList || (context.typeParameterSymbolList = createMap())).set(symbolId, true);
43054310
let typeParameterNodes: ReadonlyArray<TypeNode> | ReadonlyArray<TypeParameterDeclaration> | undefined;
43064311
if (context.flags & NodeBuilderFlags.WriteTypeParametersInQualifiedName && index < (chain.length - 1)) {
43074312
const parentSymbol = symbol;
@@ -4628,6 +4633,7 @@ namespace ts {
46284633
inferTypeParameters: TypeParameter[] | undefined;
46294634
approximateLength: number;
46304635
truncating?: boolean;
4636+
typeParameterSymbolList?: Map<true>;
46314637
}
46324638

46334639
function isDefaultBindingContext(location: Node) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
4+
//// declare namespace AMap {
5+
//// namespace MassMarks {
6+
//// interface Data {
7+
//// style?: number;
8+
//// }
9+
//// }
10+
//// class MassMarks<D extends MassMarks.Data = MassMarks.Data> {
11+
//// constructor(data: D[] | string);
12+
//// clear(): void;
13+
//// }
14+
//// }
15+
////
16+
//// interface MassMarksCustomData extends AMap.MassMarks./*1*/Data {
17+
//// name: string;
18+
//// id: string;
19+
//// }
20+
21+
verify.quickInfoAt("1", "interface AMap.MassMarks<D extends AMap.MassMarks.Data = AMap.MassMarks.Data>.Data");

0 commit comments

Comments
 (0)