Repository navigation
@overload doesn't work for constructors #52477
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.
Milestone
Description
Activity
- addedNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.
on Feb 2, 2023 - changed the title
[-]JSDoc overload syntax introduced in recent PR does not appear to work[/-][+]`@overload` doesn't work for constructors[/+]on Feb 2, 2023 Initial notes:
@constructoris unexpected in the middle of an overload, and is only useful to the checker for marking constructor functions.- All the but first comments start with
/*instead of/**.
I'm trying to get it work after removing
@constructorand adding asterisks.With the syntax corrected like so
class Foo { #a #b /** * @constructor * @overload * @param {string} a * @param {number} b *//** * @constructor * @overload * @param {number} a *//** * @constructor * @overload * @param {string} a *//** * @constructor */ constructor(a, b) { this.#a = a this.#b = b } }
Quick info starts working correctly. Type checking is still broken -- it looks like resolveCall doesn't recognise the overloads when they're for a construct signature.
Reacted by anonbergine- addedFix AvailableA PR has been opened for this issueA PR has been opened for this issue
on Feb 2, 2023 Yep, neither getReturnTypeOfSignature nor checkCallExpression recognised
@overloadand were returningany+ an error.Reacted by anonbergine- locked as resolved and limited conversation to collaborators
on Oct 22, 2025
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.
Bug Report
🔎 Search Terms
"jsdoc overload"
"constructor overload jsdoc"
"overload jsdoc example"
🕗 Version & Regression Information
I've only just tried using this feature. Specifically based on the recent merged PR #51234 which is intended to fix #25590
⏯ Playground Link
Playground link with relevant code
screenshot of playground
💻 Code
🙁 Actual behavior
Code hints are not indicating the presence of overloads, and type checking does not seem to be applied correctly based on parameter combination.
🙂 Expected behavior
While instantiating the class I would expect to see the "up/down" arrows in the code hint that indicates presence of overloads (and allows cycling through the hints for the various overloads). I would also expect type checking to be applied properly.