Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Gerrit0 opened this issue May 24, 2024 · 0 comments Β· May be fixed by #58655
Open

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

Gerrit0 opened this issue May 24, 2024 · 0 comments Β· May be fixed by #58655
Labels
Bug A bug in TypeScript
Milestone

Comments

@Gerrit0
Copy link
Contributor

Gerrit0 commented May 24, 2024

πŸ”Ž 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants