Skip to content

Commit 1ebdcc6

Browse files
authored
Fix inlay hint crash for jsdoc function type syntax (#47684)
* Fix inlay hint crash for jsdoc function type syntax Parameters in JSDoc function types do not have names. The type does not reflect this. This PR fixes the crash; I'll see how much churn it causes to fix the type as well. Fixes #47606 * make inlay hints test smaller
1 parent 7183b14 commit 1ebdcc6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31508,6 +31508,9 @@ namespace ts {
3150831508
}
3150931509

3151031510
function getParameterIdentifierNameAtPosition(signature: Signature, pos: number): [parameterName: __String, isRestParameter: boolean] | undefined {
31511+
if (signature.declaration?.kind === SyntaxKind.JSDocFunctionType) {
31512+
return undefined;
31513+
}
3151131514
const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
3151231515
if (pos < paramCount) {
3151331516
const param = signature.parameters[pos];
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// <reference path="fourslash.ts" />
2+
// @allowJs: true
3+
// @checkJs: true
4+
// @Filename: foo.js
5+
//// /**
6+
//// * @param {function(string): boolean} f
7+
//// */
8+
//// function doThing(f) {
9+
//// f(100)
10+
//// }
11+
verify.getInlayHints([], undefined, {
12+
includeInlayVariableTypeHints: true,
13+
includeInlayParameterNameHints: "all",
14+
});

0 commit comments

Comments
 (0)