fix(23716): show generic type in tagged template expression
This commit is contained in:
parent
ff36bf00e4
commit
6e98431cec
|
@ -159,14 +159,14 @@ namespace ts.SymbolDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
// try get the call/construct signature from the type if it matches
|
// try get the call/construct signature from the type if it matches
|
||||||
let callExpressionLike: CallExpression | NewExpression | JsxOpeningLikeElement | undefined;
|
let callExpressionLike: CallExpression | NewExpression | JsxOpeningLikeElement | TaggedTemplateExpression | undefined;
|
||||||
if (isCallOrNewExpression(location)) {
|
if (isCallOrNewExpression(location)) {
|
||||||
callExpressionLike = location;
|
callExpressionLike = location;
|
||||||
}
|
}
|
||||||
else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) {
|
else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) {
|
||||||
callExpressionLike = <CallExpression | NewExpression>location.parent;
|
callExpressionLike = <CallExpression | NewExpression>location.parent;
|
||||||
}
|
}
|
||||||
else if (location.parent && isJsxOpeningLikeElement(location.parent) && isFunctionLike(symbol.valueDeclaration)) {
|
else if (location.parent && (isJsxOpeningLikeElement(location.parent) || isTaggedTemplateExpression(location.parent)) && isFunctionLike(symbol.valueDeclaration)) {
|
||||||
callExpressionLike = location.parent;
|
callExpressionLike = location.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/// <reference path='fourslash.ts'/>
|
||||||
|
|
||||||
|
////interface T1 {}
|
||||||
|
////class T2 {}
|
||||||
|
////type T3 = "a" | "b";
|
||||||
|
////
|
||||||
|
////declare function foo<T>(strings: TemplateStringsArray, ...values: T[]): void;
|
||||||
|
////
|
||||||
|
/////*1*/foo<number>``;
|
||||||
|
/////*2*/foo<string | number>``;
|
||||||
|
/////*3*/foo<{ a: number }>``;
|
||||||
|
/////*4*/foo<T1>``;
|
||||||
|
/////*5*/foo<T2>``;
|
||||||
|
/////*6*/foo<T3>``;
|
||||||
|
/////*7*/foo``;
|
||||||
|
|
||||||
|
verify.quickInfoAt("1", "function foo<number>(strings: TemplateStringsArray, ...values: number[]): void");
|
||||||
|
verify.quickInfoAt("2", "function foo<string | number>(strings: TemplateStringsArray, ...values: (string | number)[]): void");
|
||||||
|
verify.quickInfoAt("3",
|
||||||
|
`function foo<{
|
||||||
|
a: number;
|
||||||
|
}>(strings: TemplateStringsArray, ...values: {
|
||||||
|
a: number;
|
||||||
|
}[]): void`);
|
||||||
|
verify.quickInfoAt("4", "function foo<T1>(strings: TemplateStringsArray, ...values: T1[]): void");
|
||||||
|
verify.quickInfoAt("5", "function foo<T2>(strings: TemplateStringsArray, ...values: T2[]): void");
|
||||||
|
verify.quickInfoAt("6", "function foo<T3>(strings: TemplateStringsArray, ...values: T3[]): void");
|
||||||
|
verify.quickInfoAt("7", "function foo<unknown>(strings: TemplateStringsArray, ...values: unknown[]): void");
|
Loading…
Reference in a new issue