Skip to content

Commit 6128f30

Browse files
Merge pull request #38821 from a-tarasyuk/bug/23716
fix(23716): signature help of tagged template doesn't show instantiated signature
2 parents ec4cf68 + 6e98431 commit 6128f30

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/services/symbolDisplay.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,14 @@ namespace ts.SymbolDisplay {
159159
}
160160

161161
// try get the call/construct signature from the type if it matches
162-
let callExpressionLike: CallExpression | NewExpression | JsxOpeningLikeElement | undefined;
162+
let callExpressionLike: CallExpression | NewExpression | JsxOpeningLikeElement | TaggedTemplateExpression | undefined;
163163
if (isCallOrNewExpression(location)) {
164164
callExpressionLike = location;
165165
}
166166
else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) {
167167
callExpressionLike = <CallExpression | NewExpression>location.parent;
168168
}
169-
else if (location.parent && isJsxOpeningLikeElement(location.parent) && isFunctionLike(symbol.valueDeclaration)) {
169+
else if (location.parent && (isJsxOpeningLikeElement(location.parent) || isTaggedTemplateExpression(location.parent)) && isFunctionLike(symbol.valueDeclaration)) {
170170
callExpressionLike = location.parent;
171171
}
172172

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////interface T1 {}
4+
////class T2 {}
5+
////type T3 = "a" | "b";
6+
////
7+
////declare function foo<T>(strings: TemplateStringsArray, ...values: T[]): void;
8+
////
9+
/////*1*/foo<number>``;
10+
/////*2*/foo<string | number>``;
11+
/////*3*/foo<{ a: number }>``;
12+
/////*4*/foo<T1>``;
13+
/////*5*/foo<T2>``;
14+
/////*6*/foo<T3>``;
15+
/////*7*/foo``;
16+
17+
verify.quickInfoAt("1", "function foo<number>(strings: TemplateStringsArray, ...values: number[]): void");
18+
verify.quickInfoAt("2", "function foo<string | number>(strings: TemplateStringsArray, ...values: (string | number)[]): void");
19+
verify.quickInfoAt("3",
20+
`function foo<{
21+
a: number;
22+
}>(strings: TemplateStringsArray, ...values: {
23+
a: number;
24+
}[]): void`);
25+
verify.quickInfoAt("4", "function foo<T1>(strings: TemplateStringsArray, ...values: T1[]): void");
26+
verify.quickInfoAt("5", "function foo<T2>(strings: TemplateStringsArray, ...values: T2[]): void");
27+
verify.quickInfoAt("6", "function foo<T3>(strings: TemplateStringsArray, ...values: T3[]): void");
28+
verify.quickInfoAt("7", "function foo<unknown>(strings: TemplateStringsArray, ...values: unknown[]): void");

0 commit comments

Comments
 (0)