Skip to content

Support jsdocs overloading #46166

Closed
Closed
@OhadBaehr

Description

@OhadBaehr
/**
* move to coords
*
* @param {number} x X coordinate
* @param {number} y Y coordinate
* @param {object} [opts] options
* @param {boolean} [opts.opt1] option 1
* @param {number} [opts.opt2] option 2
*//**
* move to point
*
* @param {object} target point struct
* @param {object} [opts] options
* @param {boolean} [opts.opt1] option 1
* @param {number} [opts.opt2] option 2
*/
function move(arg1, arg2, arg3) {
   let x, y, opts;
   if (typeof arg1 === "object") {
       x = arg1.x;
       y = arg1.y;
       opts = arg2;
   } else {
       x = arg1;
       y = arg2;
       opts = arg3;
   }
   // do some stuff
}

move(1, 2, {opt1: true});
move({x: 1, y: 2}, {opt1: true});

This code should have 2 overload options, VSCode only picks one.
Please make it possible to have function overloading using JSDocs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: JSDocRelates to JSDoc parsing and type generationDuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions