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 +});