microsoft / microsoft/TypeScript

Intersection type intellisense duplicates jsdoc, rather than overriding

未关闭
#30,901 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Experience Enhancement Suggestion
主要语言
Go
星标
111k
派生
14.4k
平均合并
1 天 19 小时
30 天内合并 PR
117

描述

  • VSCode Version: 1.33.1
  • OS Version: macOS 10.12.6

Does this issue occur when all extensions are disabled?: Yes


Sorry if the title isn't clear, it's tricky to put into words but obvious with code. The gist is when a type is extended and has the same key, the intellisense combines the documentation, rather than the "child" overriding it, like they do with interface. It's easier to explain with an example.

When intersecting types with the same property, the intellisense documentation shows all of the comments instead of just the latest:

type Duck {
  /** This is a really great duck */
  id: string
}

type Mallard = Duck & {
  /** I love this duck */
  id: string
}

const duckMan: Mallard = {
  id   // intellisense here shows "This is a really great duck I love this duck"
}
Pasted_Image_4_12_19__4_05_PM

However, with an interface, the intellisense shows only the direct type comment, which is expected.

interface Duck {
  /** This is a really great banana */
  id: string
}

interface Mallard extends Duck {
  /** I love this duck */
  id: string
}

const duckMan: Mallard = {
  id // Intellisense says "I love this duck"
}
Pasted_Image_4_12_19__4_05_PM

I found this out because I'm using graphql-codegen to generate types for my GraphQL schema. It generates types, and the intellisense in some cases repeats many times.

Expectation

I would expect the "closest" comment doc of a type to override all of the others, like it does with an interface. If there's a reason that can't work, then at least having a uniqueness check would be good, maybe new Set(typedocs))

贡献指南

打开贡献指南

从这里开始

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

调研方向

未指定源文件或测试。首先在 TypeScript IntelliSense 中复现提供的交叉类型和接口示例,然后跟踪 language-service 对交叉属性的 JSDoc 的处理;当显示最接近类型的文档且不重复继承的注释时,即视为完成。

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

评估

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

把新 issue 发到你的邮箱

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