microsoft / microsoft/TypeScript

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

未关闭
#58,653 0 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Domain: Declaration Emit
主要语言
Go
星标
111k
派生
14.4k
平均合并
1 天 19 小时
30 天内合并 PR
117

描述

🔎 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.

https://github.com/TypeStrong/typedoc/issues/2577

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从链接的 TypeScript Playground 复现开始,使用 foo.js,并将生成的声明文件与预期输出进行比较。跟踪无参数构造函数的 @private JSDoc 在声明生成期间是如何表示的。完成标准是生成的 .d.ts 保留私有构造函数及其文档,同时不改变报告的构造函数访问行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, typescript
领域
compilers
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。