Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/services/inlayHints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -202,18 +202,14 @@ 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;
return isLiteralExpression(operand) || isIdentifier(operand) && isInfinityOrNaNString(operand.escapedText);
}
case SyntaxKind.TrueKeyword:
case SyntaxKind.FalseKeyword:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.NullKeyword:
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.TemplateExpression:
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork12.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ verify.getInlayHints([
whitespaceAfter: true
},
], undefined, {
includeInlayParameterNameHints: "literals"
includeInlayParameterNameHints: "all"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork29.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ verify.getInlayHints([
whitespaceBefore: true
}
], undefined, {
includeInlayParameterNameHints: "literals",
includeInlayParameterNameHints: "all",
includeInlayFunctionParameterTypeHints: true
});
6 changes: 0 additions & 6 deletions tests/cases/fourslash/inlayHintsShouldWork34.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Comment on lines -8 to -13
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inlayHintsShouldWork35 covers the all case.


//// foo(foo);
//// foo(/*j*/(1));
Expand Down