From 25d024f898762f37fe36ffd6dcb5ae28cc3776dc Mon Sep 17 00:00:00 2001
From: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
Date: Mon, 23 Aug 2021 16:38:26 -0700
Subject: [PATCH] Only provide hints for simple literals when 'literals' is
 specified. (#45557)

* Only provide hints for simple literals when 'literals' is specified.

* Update fourslash tests.
---
 src/services/inlayHints.ts                      | 8 ++------
 tests/cases/fourslash/inlayHintsShouldWork12.ts | 2 +-
 tests/cases/fourslash/inlayHintsShouldWork29.ts | 2 +-
 tests/cases/fourslash/inlayHintsShouldWork34.ts | 6 ------
 4 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/src/services/inlayHints.ts b/src/services/inlayHints.ts
index b37a9be01c2a0..404e1232c77ca 100644
--- a/src/services/inlayHints.ts
+++ b/src/services/inlayHints.ts
@@ -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.FunctionExpression:
-                case SyntaxKind.ArrowFunction:
-                case SyntaxKind.ObjectLiteralExpression:
-                case SyntaxKind.ArrayLiteralExpression:
                 case SyntaxKind.NullKeyword:
                 case SyntaxKind.NoSubstitutionTemplateLiteral:
                 case SyntaxKind.TemplateExpression:
diff --git a/tests/cases/fourslash/inlayHintsShouldWork12.ts b/tests/cases/fourslash/inlayHintsShouldWork12.ts
index 8414ca08c97e0..0d2471eb6c828 100644
--- a/tests/cases/fourslash/inlayHintsShouldWork12.ts
+++ b/tests/cases/fourslash/inlayHintsShouldWork12.ts
@@ -21,5 +21,5 @@ verify.getInlayHints([
         whitespaceAfter: true
     },
 ], undefined, {
-    includeInlayParameterNameHints: "literals"
+    includeInlayParameterNameHints: "all"
 });
diff --git a/tests/cases/fourslash/inlayHintsShouldWork29.ts b/tests/cases/fourslash/inlayHintsShouldWork29.ts
index f371e2c552633..5eb157d582351 100644
--- a/tests/cases/fourslash/inlayHintsShouldWork29.ts
+++ b/tests/cases/fourslash/inlayHintsShouldWork29.ts
@@ -32,6 +32,6 @@ verify.getInlayHints([
         whitespaceBefore: true
     }
 ], undefined, {
-    includeInlayParameterNameHints: "literals",
+    includeInlayParameterNameHints: "all",
     includeInlayFunctionParameterTypeHints: true
 });
diff --git a/tests/cases/fourslash/inlayHintsShouldWork34.ts b/tests/cases/fourslash/inlayHintsShouldWork34.ts
index 6c5f87a78340f..8aa03a8d4af6e 100644
--- a/tests/cases/fourslash/inlayHintsShouldWork34.ts
+++ b/tests/cases/fourslash/inlayHintsShouldWork34.ts
@@ -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));