microsoft / microsoft/TypeScript
JSDoc `@private` on constructor without parameters is omitted in declaration files
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 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
💻 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked TypeScript Playground reproduction using foo.js and compare the emitted declaration file with the expected output. Trace how the parameterless constructor's @private JSDoc is represented during declaration generation. Done means the emitted .d.ts preserves the private constructor and its documentation without changing the reported constructor access behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100