Skip to content

Documenting a class returning another class #1729

Open
@OmgImAlexis

Description

@OmgImAlexis

Input code

/**
 * Canvas
 *
 * @class Canvas
 */
class Canvas {
    /**
     * Creates an instance of Canvas.
     * @returns {HTMLCanvasElement}
     * @memberof Canvas
     */
    constructor(width, height) {
        const canvas = document.createElement('canvas');
        canvas.width = width;
        canvas.height = height;

        return canvas;
    }
};

Expected behavior

This is the js output, so I know this works.

const canvas = new Canvas(600, 800);
console.log(canvas.width); // 600

Current behavior

This is what happens when using a jsdoc plugin and hover over the width.
I would have expected the width to show that it's a number.

const canvas = new Canvas(600, 800);
console.log(canvas.width); // `undefined`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions