Skip to content

JSDoc @private on constructor without parameters is omitted in declaration filesΒ #58653

@Gerrit0

Description

@Gerrit0

πŸ”Ž Search Terms

jsdoc private constructor

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried back through TS 3.8 where JSDoc support was added, and I reviewed the FAQ for entries about JSDoc

⏯ Playground Link

https://www.typescriptlang.org/play/?target=99&module=1&ts=5.5.0-beta&ssl=8&ssc=10&pln=1&pc=1&filetype=js#code/MYGwhgzhAEBiD29oG8BQ0PQPQCofs2h2gAEAHAJwEsA3MAFwFMDMcsXph4A7CeigK7B68CgAoAlCgC+qWam6MA7nESSgA

πŸ’» Code

// foo.js
class Foo {
    /**
     * @private
     */
    constructor() {}
}

new Foo()
// Constructor of class 'Foo' is private and only accessible within the class declaration.(2673)

πŸ™ Actual behavior

Emits the declaration file:

declare class Foo {
}

πŸ™‚ Expected behavior

Should emit the declaration file:

declare class Foo {
    /**
     * @private
     */
    private constructor();
}

Additional information about the issue

I ran into this as it was requested that TypeDoc add a new JSDoc tag to work around this issue. This seems wrong since the declaration file doesn't accurately describe the types within the file, but it's also very unfortunate that it results in the loss of any documentation added to the constructor.

TypeStrong/typedoc#2577

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions