mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
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:
parent
7183b14831
commit
1ebdcc6fb8
@ -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];
|
||||
|
||||
14
tests/cases/fourslash/inlayHintsCrash1.ts
Normal file
14
tests/cases/fourslash/inlayHintsCrash1.ts
Normal 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",
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user