From 8a2f5b2a6b971f20feca5feb985d7387e4066d8b Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Wed, 29 Sep 2021 19:28:23 +0300 Subject: [PATCH] fix(45999): show parameter inlay hints before initializer (#46040) --- src/services/inlayHints.ts | 2 +- .../cases/fourslash/inlayHintsShouldWork65.ts | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/inlayHintsShouldWork65.ts diff --git a/src/services/inlayHints.ts b/src/services/inlayHints.ts index 404e1232c77..59add59b0ae 100644 --- a/src/services/inlayHints.ts +++ b/src/services/inlayHints.ts @@ -279,7 +279,7 @@ namespace ts.InlayHints { continue; } - addTypeHints(typeDisplayString, param.end); + addTypeHints(typeDisplayString, param.name.end); } } diff --git a/tests/cases/fourslash/inlayHintsShouldWork65.ts b/tests/cases/fourslash/inlayHintsShouldWork65.ts new file mode 100644 index 00000000000..a80c102149d --- /dev/null +++ b/tests/cases/fourslash/inlayHintsShouldWork65.ts @@ -0,0 +1,22 @@ +/// + +//// type F = (a: string, b: number) => void +//// const f: F = (a/*a*/, b/*b*/ = 1) => { } + +const [a, b] = test.markers(); +verify.getInlayHints([ + { + text: ': string', + position: a.position, + kind: ts.InlayHintKind.Type, + whitespaceBefore: true + }, + { + text: ': number', + position: b.position, + kind: ts.InlayHintKind.Type, + whitespaceBefore: true + } +], undefined, { + includeInlayFunctionParameterTypeHints: true +});