-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
Needs InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
Description
Bug Report
π Search Terms
jsdoc infer function return any
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
jsdoc
β― Playground Link
Playground link with relevant code
π» Code
/**
* @template T
* @typedef {T extends boolean ? T : T} ConvertPuppeteerArgument
*/
// Uncomment the next line in order to fix the issue:
// {}
/**
* @template A
* @template R
* @param {(arg: ConvertPuppeteerArgument<A>) => R} fn
* @param {A} arg
*/
export function runFunction(fn, arg) {
return /** @type {R} */ ({});
}
const returnedValue = runFunction((str) => true, "str");
returnedValue; // `any`, but should be `boolean`π Actual behavior
returnedValue has the type any
π Expected behavior
returnedValue has the type boolean, because the equivalent TypeScript also functions this way.
Furthermore, adding {} in between the two jsdoc comments fixes the issue, having extra jsdoc comments above a function should not affect its return value.
Possible duplicate: #43913, although I haven't been able to reduce this test case further to something like in that issue, so this might be caused by something else.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone