Only provide hints for simple literals when 'literals' is specified. (#45557)
* Only provide hints for simple literals when 'literals' is specified. * Update fourslash tests.
This commit is contained in:
parent
d2a46a07b3
commit
5719423aad
|
@ -156,7 +156,7 @@ namespace ts.InlayHints {
|
|||
for (let i = 0; i < args.length; ++i) {
|
||||
const originalArg = args[i];
|
||||
const arg = skipParentheses(originalArg);
|
||||
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableExpression(arg)) {
|
||||
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ namespace ts.InlayHints {
|
|||
return some(ranges, range => regex.test(sourceFileText.substring(range.pos, range.end)));
|
||||
}
|
||||
|
||||
function isHintableExpression(node: Node) {
|
||||
function isHintableLiteral(node: Node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.PrefixUnaryExpression: {
|
||||
const operand = (node as PrefixUnaryExpression).operand;
|
||||
|
@ -210,10 +210,6 @@ namespace ts.InlayHints {
|
|||
}
|
||||
case SyntaxKind.TrueKeyword:
|
||||
case SyntaxKind.FalseKeyword:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.NullKeyword:
|
||||
return true;
|
||||
case SyntaxKind.Identifier: {
|
||||
|
|
|
@ -21,5 +21,5 @@ verify.getInlayHints([
|
|||
whitespaceAfter: true
|
||||
},
|
||||
], undefined, {
|
||||
includeInlayParameterNameHints: "literals"
|
||||
includeInlayParameterNameHints: "all"
|
||||
});
|
||||
|
|
|
@ -32,6 +32,6 @@ verify.getInlayHints([
|
|||
whitespaceBefore: true
|
||||
}
|
||||
], undefined, {
|
||||
includeInlayParameterNameHints: "literals",
|
||||
includeInlayParameterNameHints: "all",
|
||||
includeInlayFunctionParameterTypeHints: true
|
||||
});
|
||||
|
|
|
@ -5,12 +5,6 @@
|
|||
//// foo(/*a*/1);
|
||||
//// foo(/*b*/'');
|
||||
//// foo(/*c*/true);
|
||||
//// foo(/*d*/() => 1);
|
||||
//// foo(/*e*/function () { return 1 });
|
||||
//// foo(/*f*/{});
|
||||
//// foo(/*g*/{ a: 1 });
|
||||
//// foo(/*h*/[]);
|
||||
//// foo(/*i*/[1]);
|
||||
|
||||
//// foo(foo);
|
||||
//// foo(/*j*/(1));
|
||||
|
|
Loading…
Reference in a new issue