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
This commit is contained in:
Nathan Shively-Sanders 2022-02-01 10:11:39 -08:00 committed by GitHub
parent 7183b14831
commit 1ebdcc6fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -31508,6 +31508,9 @@ namespace ts {
}
function getParameterIdentifierNameAtPosition(signature: Signature, pos: number): [parameterName: __String, isRestParameter: boolean] | undefined {
if (signature.declaration?.kind === SyntaxKind.JSDocFunctionType) {
return undefined;
}
const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
if (pos < paramCount) {
const param = signature.parameters[pos];

View File

@ -0,0 +1,14 @@
/// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: foo.js
//// /**
//// * @param {function(string): boolean} f
//// */
//// function doThing(f) {
//// f(100)
//// }
verify.getInlayHints([], undefined, {
includeInlayVariableTypeHints: true,
includeInlayParameterNameHints: "all",
});