Skip to content

Commit 245ae95

Browse files
authored
fix(3605): Missing generic param displayed in hover (#3606)
1 parent 2a3f6d2 commit 245ae95

7 files changed

Lines changed: 40 additions & 40 deletions

File tree

internal/checker/nodebuilderimpl.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3480,7 +3480,13 @@ func (b *NodeBuilderImpl) lookupExpressionChainTypeArgumentNodes(chain []*ast.Sy
34803480
}
34813481

34823482
b.ctx.typeParameterSymbolList[symbolId] = struct{}{}
3483-
return b.lookupInstantiatedTypeArgumentNodes(chain, index)
3483+
if typeArgumentNodes := b.lookupInstantiatedTypeArgumentNodes(chain, index); typeArgumentNodes != nil {
3484+
return typeArgumentNodes
3485+
}
3486+
typeParameterNodes := b.typeParametersToTypeParameterDeclarations(symbol)
3487+
if len(typeParameterNodes) > 0 {
3488+
return b.f.NewNodeList(typeParameterNodes)
3489+
}
34843490
}
34853491
return nil
34863492
}

internal/fourslash/_scripts/failingTests.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ TestCommentsInheritanceFourslash
4646
TestCommentsInterfaceFourslash
4747
TestCommentsLinePreservation
4848
TestCommentsOverloadsFourslash
49-
TestCommentsUnion
5049
TestCommentsVariables
5150
TestCompletionAfterQuestionDot
5251
TestCompletionAutoInsertQuestionDot
@@ -247,7 +246,6 @@ TestImportTypeCompletions7
247246
TestImportTypeCompletions8
248247
TestImportTypeCompletions9
249248
TestIndirectClassInstantiation
250-
TestInstanceTypesForGenericType1
251249
TestJavascriptModules20
252250
TestJavascriptModules24
253251
TestJsDocAugments
@@ -283,7 +281,6 @@ TestJsxAttributeCompletionStyleNoSnippet
283281
TestJsxAttributeSnippetCompletionAfterTypeArgs
284282
TestJsxAttributeSnippetCompletionClosed
285283
TestJsxAttributeSnippetCompletionUnclosed
286-
TestJsxGenericQuickInfo
287284
TestJsxWithTypeParametershasInstantiatedSignatureHelp
288285
TestLetQuickInfoAndCompletionList
289286
TestLocalFunction
@@ -310,11 +307,9 @@ TestQuickInfoElementAccessDeclaration
310307
TestQuickInfoForConstTypeReference
311308
TestQuickInfoForContextuallyTypedArrowFunctionInSuperCall
312309
TestQuickInfoForGenericConstraints1
313-
TestQuickInfoForGenericPrototypeMember
314310
TestQuickInfoForGenericTaggedTemplateExpression
315311
TestQuickInfoForGetterAndSetter
316312
TestQuickInfoForIndexerResultWithConstraint
317-
TestQuickinfoForNamespaceMergeWithClassConstrainedToSelf
318313
TestQuickInfoForTypeofParameter
319314
TestQuickInfoForTypeParameterInTypeAlias2
320315
TestQuickInfoForUMDModuleAlias
@@ -363,7 +358,6 @@ TestQuickInfoOnVarInArrowExpression
363358
TestQuickInfoPrivateIdentifierInTypeReferenceNoCrash1
364359
TestQuickInfoPropertyTag
365360
TestQuickInfoSpecialPropertyAssignment
366-
TestQuickInfoStaticPrototypePropertyOnClass
367361
TestQuickInfoTemplateTag
368362
TestQuickInfoTypeAliasDefinedInDifferentFile
369363
TestQuickInfoTypeError

internal/printer/printer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1877,7 +1877,7 @@ func (p *Printer) emitTypeArguments(parentNode *ast.Node, nodes *ast.TypeArgumen
18771877
if nodes == nil {
18781878
return
18791879
}
1880-
p.emitList((*Printer).emitTypeArgument, parentNode, nodes, LFTypeArguments /*|core.IfElse(p.shouldAllowTrailingComma(parentNode, nodes), LFAllowTrailingComma, LFNone)*/) // TODO: preserve trailing comma after Strada migration
1880+
p.emitList((*Printer).emitTypeParameterDeclarationNode, parentNode, nodes, LFTypeArguments /*|core.IfElse(p.shouldAllowTrailingComma(parentNode, nodes), LFAllowTrailingComma, LFNone)*/) // TODO: preserve trailing comma after Strada migration
18811881
}
18821882

18831883
func (p *Printer) emitTypeReference(node *ast.TypeReferenceNode) {

testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInClass.baseline

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242
// ^^^^^^
4343
// | ----------------------------------------------------------------------
4444
// | ```typescript
45-
// | (method) c.method<U>(a: U, b: T): U
45+
// | (method) c<T>.method<U>(a: U, b: T): U
4646
// | ```
4747
// |
4848
// | ----------------------------------------------------------------------
4949
// ^
5050
// | ----------------------------------------------------------------------
5151
// | ```typescript
52-
// | (type parameter) U in c.method<U>(a: U, b: T): U
52+
// | (type parameter) U in c<T>.method<U>(a: U, b: T): U
5353
// | ```
5454
// |
5555
// | ----------------------------------------------------------------------
@@ -63,7 +63,7 @@
6363
// ^
6464
// | ----------------------------------------------------------------------
6565
// | ```typescript
66-
// | (type parameter) U in c.method<U>(a: U, b: T): U
66+
// | (type parameter) U in c<T>.method<U>(a: U, b: T): U
6767
// | ```
6868
// |
6969
// | ----------------------------------------------------------------------
@@ -185,14 +185,14 @@
185185
// ^^^^^^
186186
// | ----------------------------------------------------------------------
187187
// | ```typescript
188-
// | (method) c2.method<U extends c<string>>(a: U, b: T): U
188+
// | (method) c2<T extends c<string>>.method<U extends c<string>>(a: U, b: T): U
189189
// | ```
190190
// |
191191
// | ----------------------------------------------------------------------
192192
// ^
193193
// | ----------------------------------------------------------------------
194194
// | ```typescript
195-
// | (type parameter) U extends c<string> in c2.method<U extends c<string>>(a: U, b: T): U
195+
// | (type parameter) U extends c<string> in c2<T extends c<string>>.method<U extends c<string>>(a: U, b: T): U
196196
// | ```
197197
// |
198198
// | ----------------------------------------------------------------------
@@ -213,7 +213,7 @@
213213
// ^
214214
// | ----------------------------------------------------------------------
215215
// | ```typescript
216-
// | (type parameter) U extends c<string> in c2.method<U extends c<string>>(a: U, b: T): U
216+
// | (type parameter) U extends c<string> in c2<T extends c<string>>.method<U extends c<string>>(a: U, b: T): U
217217
// | ```
218218
// |
219219
// | ----------------------------------------------------------------------
@@ -458,7 +458,7 @@
458458
"item": {
459459
"contents": {
460460
"kind": "markdown",
461-
"value": "```typescript\n(method) c.method<U>(a: U, b: T): U\n```\n"
461+
"value": "```typescript\n(method) c<T>.method<U>(a: U, b: T): U\n```\n"
462462
},
463463
"range": {
464464
"start": {
@@ -485,7 +485,7 @@
485485
"item": {
486486
"contents": {
487487
"kind": "markdown",
488-
"value": "```typescript\n(type parameter) U in c.method<U>(a: U, b: T): U\n```\n"
488+
"value": "```typescript\n(type parameter) U in c<T>.method<U>(a: U, b: T): U\n```\n"
489489
},
490490
"range": {
491491
"start": {
@@ -539,7 +539,7 @@
539539
"item": {
540540
"contents": {
541541
"kind": "markdown",
542-
"value": "```typescript\n(type parameter) U in c.method<U>(a: U, b: T): U\n```\n"
542+
"value": "```typescript\n(type parameter) U in c<T>.method<U>(a: U, b: T): U\n```\n"
543543
},
544544
"range": {
545545
"start": {
@@ -982,7 +982,7 @@
982982
"item": {
983983
"contents": {
984984
"kind": "markdown",
985-
"value": "```typescript\n(method) c2.method<U extends c<string>>(a: U, b: T): U\n```\n"
985+
"value": "```typescript\n(method) c2<T extends c<string>>.method<U extends c<string>>(a: U, b: T): U\n```\n"
986986
},
987987
"range": {
988988
"start": {
@@ -1010,7 +1010,7 @@
10101010
"item": {
10111011
"contents": {
10121012
"kind": "markdown",
1013-
"value": "```typescript\n(type parameter) U extends c<string> in c2.method<U extends c<string>>(a: U, b: T): U\n```\n"
1013+
"value": "```typescript\n(type parameter) U extends c<string> in c2<T extends c<string>>.method<U extends c<string>>(a: U, b: T): U\n```\n"
10141014
},
10151015
"range": {
10161016
"start": {
@@ -1094,7 +1094,7 @@
10941094
"item": {
10951095
"contents": {
10961096
"kind": "markdown",
1097-
"value": "```typescript\n(type parameter) U extends c<string> in c2.method<U extends c<string>>(a: U, b: T): U\n```\n"
1097+
"value": "```typescript\n(type parameter) U extends c<string> in c2<T extends c<string>>.method<U extends c<string>>(a: U, b: T): U\n```\n"
10981098
},
10991099
"range": {
11001100
"start": {

testdata/baselines/reference/fourslash/quickInfo/quickInfoDisplayPartsTypeParameterInInterface.baseline

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@
105105
// ^^^^^^
106106
// | ----------------------------------------------------------------------
107107
// | ```typescript
108-
// | (method) I.method<U>(a: U, b: T): U
108+
// | (method) I<T>.method<U>(a: U, b: T): U
109109
// | ```
110110
// |
111111
// | ----------------------------------------------------------------------
112112
// ^
113113
// | ----------------------------------------------------------------------
114114
// | ```typescript
115-
// | (type parameter) U in I.method<U>(a: U, b: T): U
115+
// | (type parameter) U in I<T>.method<U>(a: U, b: T): U
116116
// | ```
117117
// |
118118
// | ----------------------------------------------------------------------
@@ -126,7 +126,7 @@
126126
// ^
127127
// | ----------------------------------------------------------------------
128128
// | ```typescript
129-
// | (type parameter) U in I.method<U>(a: U, b: T): U
129+
// | (type parameter) U in I<T>.method<U>(a: U, b: T): U
130130
// | ```
131131
// |
132132
// | ----------------------------------------------------------------------
@@ -147,7 +147,7 @@
147147
// ^
148148
// | ----------------------------------------------------------------------
149149
// | ```typescript
150-
// | (type parameter) U in I.method<U>(a: U, b: T): U
150+
// | (type parameter) U in I<T>.method<U>(a: U, b: T): U
151151
// | ```
152152
// |
153153
// | ----------------------------------------------------------------------
@@ -324,14 +324,14 @@
324324
// ^^^^^^
325325
// | ----------------------------------------------------------------------
326326
// | ```typescript
327-
// | (method) I1.method<U extends I<string>>(a: U, b: T): U
327+
// | (method) I1<T extends I<string>>.method<U extends I<string>>(a: U, b: T): U
328328
// | ```
329329
// |
330330
// | ----------------------------------------------------------------------
331331
// ^
332332
// | ----------------------------------------------------------------------
333333
// | ```typescript
334-
// | (type parameter) U extends I<string> in I1.method<U extends I<string>>(a: U, b: T): U
334+
// | (type parameter) U extends I<string> in I1<T extends I<string>>.method<U extends I<string>>(a: U, b: T): U
335335
// | ```
336336
// |
337337
// | ----------------------------------------------------------------------
@@ -352,7 +352,7 @@
352352
// ^
353353
// | ----------------------------------------------------------------------
354354
// | ```typescript
355-
// | (type parameter) U extends I<string> in I1.method<U extends I<string>>(a: U, b: T): U
355+
// | (type parameter) U extends I<string> in I1<T extends I<string>>.method<U extends I<string>>(a: U, b: T): U
356356
// | ```
357357
// |
358358
// | ----------------------------------------------------------------------
@@ -373,7 +373,7 @@
373373
// ^
374374
// | ----------------------------------------------------------------------
375375
// | ```typescript
376-
// | (type parameter) U extends I<string> in I1.method<U extends I<string>>(a: U, b: T): U
376+
// | (type parameter) U extends I<string> in I1<T extends I<string>>.method<U extends I<string>>(a: U, b: T): U
377377
// | ```
378378
// |
379379
// | ----------------------------------------------------------------------
@@ -866,7 +866,7 @@
866866
"item": {
867867
"contents": {
868868
"kind": "markdown",
869-
"value": "```typescript\n(method) I.method<U>(a: U, b: T): U\n```\n"
869+
"value": "```typescript\n(method) I<T>.method<U>(a: U, b: T): U\n```\n"
870870
},
871871
"range": {
872872
"start": {
@@ -893,7 +893,7 @@
893893
"item": {
894894
"contents": {
895895
"kind": "markdown",
896-
"value": "```typescript\n(type parameter) U in I.method<U>(a: U, b: T): U\n```\n"
896+
"value": "```typescript\n(type parameter) U in I<T>.method<U>(a: U, b: T): U\n```\n"
897897
},
898898
"range": {
899899
"start": {
@@ -947,7 +947,7 @@
947947
"item": {
948948
"contents": {
949949
"kind": "markdown",
950-
"value": "```typescript\n(type parameter) U in I.method<U>(a: U, b: T): U\n```\n"
950+
"value": "```typescript\n(type parameter) U in I<T>.method<U>(a: U, b: T): U\n```\n"
951951
},
952952
"range": {
953953
"start": {
@@ -1028,7 +1028,7 @@
10281028
"item": {
10291029
"contents": {
10301030
"kind": "markdown",
1031-
"value": "```typescript\n(type parameter) U in I.method<U>(a: U, b: T): U\n```\n"
1031+
"value": "```typescript\n(type parameter) U in I<T>.method<U>(a: U, b: T): U\n```\n"
10321032
},
10331033
"range": {
10341034
"start": {
@@ -1696,7 +1696,7 @@
16961696
"item": {
16971697
"contents": {
16981698
"kind": "markdown",
1699-
"value": "```typescript\n(method) I1.method<U extends I<string>>(a: U, b: T): U\n```\n"
1699+
"value": "```typescript\n(method) I1<T extends I<string>>.method<U extends I<string>>(a: U, b: T): U\n```\n"
17001700
},
17011701
"range": {
17021702
"start": {
@@ -1724,7 +1724,7 @@
17241724
"item": {
17251725
"contents": {
17261726
"kind": "markdown",
1727-
"value": "```typescript\n(type parameter) U extends I<string> in I1.method<U extends I<string>>(a: U, b: T): U\n```\n"
1727+
"value": "```typescript\n(type parameter) U extends I<string> in I1<T extends I<string>>.method<U extends I<string>>(a: U, b: T): U\n```\n"
17281728
},
17291729
"range": {
17301730
"start": {
@@ -1808,7 +1808,7 @@
18081808
"item": {
18091809
"contents": {
18101810
"kind": "markdown",
1811-
"value": "```typescript\n(type parameter) U extends I<string> in I1.method<U extends I<string>>(a: U, b: T): U\n```\n"
1811+
"value": "```typescript\n(type parameter) U extends I<string> in I1<T extends I<string>>.method<U extends I<string>>(a: U, b: T): U\n```\n"
18121812
},
18131813
"range": {
18141814
"start": {
@@ -1892,7 +1892,7 @@
18921892
"item": {
18931893
"contents": {
18941894
"kind": "markdown",
1895-
"value": "```typescript\n(type parameter) U extends I<string> in I1.method<U extends I<string>>(a: U, b: T): U\n```\n"
1895+
"value": "```typescript\n(type parameter) U extends I<string> in I1<T extends I<string>>.method<U extends I<string>>(a: U, b: T): U\n```\n"
18961896
},
18971897
"range": {
18981898
"start": {

testdata/baselines/reference/fourslash/quickInfo/quickInfoInheritDoc2.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// ^^^^
1717
// | ----------------------------------------------------------------------
1818
// | ```typescript
19-
// | (property) SubClass.prop: T | undefined
19+
// | (property) SubClass<T>.prop: T | undefined
2020
// | ```
2121
// |
2222
// |
@@ -38,7 +38,7 @@
3838
"item": {
3939
"contents": {
4040
"kind": "markdown",
41-
"value": "```typescript\n(property) SubClass.prop: T | undefined\n```\n\n\n*@inheritdoc* — SubClass.prop\n"
41+
"value": "```typescript\n(property) SubClass<T>.prop: T | undefined\n```\n\n\n*@inheritdoc* — SubClass.prop\n"
4242
},
4343
"range": {
4444
"start": {

testdata/baselines/reference/fourslash/quickInfo/quickInfoLink3.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// ^^^
1414
// | ----------------------------------------------------------------------
1515
// | ```typescript
16-
// | (method) Foo.bar(): void
16+
// | (method) Foo<T>.bar(): void
1717
// | ```
1818
// | [Foo](file:///quickInfoLink3.ts#1,7-1,10)
1919
// | [<T>](file:///quickInfoLink3.ts#1,7-1,10)
@@ -37,7 +37,7 @@
3737
"item": {
3838
"contents": {
3939
"kind": "markdown",
40-
"value": "```typescript\n(method) Foo.bar(): void\n```\n[Foo](file:///quickInfoLink3.ts#1,7-1,10)\n[<T>](file:///quickInfoLink3.ts#1,7-1,10)\n[<Array<X>>](file:///quickInfoLink3.ts#1,7-1,10)\n[<>](file:///quickInfoLink3.ts#1,7-1,10)\n[>](file:///quickInfoLink3.ts#1,7-1,10)\n[<](file:///quickInfoLink3.ts#1,7-1,10)"
40+
"value": "```typescript\n(method) Foo<T>.bar(): void\n```\n[Foo](file:///quickInfoLink3.ts#1,7-1,10)\n[<T>](file:///quickInfoLink3.ts#1,7-1,10)\n[<Array<X>>](file:///quickInfoLink3.ts#1,7-1,10)\n[<>](file:///quickInfoLink3.ts#1,7-1,10)\n[>](file:///quickInfoLink3.ts#1,7-1,10)\n[<](file:///quickInfoLink3.ts#1,7-1,10)"
4141
},
4242
"range": {
4343
"start": {

0 commit comments

Comments
 (0)