Incorrect docs: type compatibility for functions with overloads

未关闭 适合新手
#30,075 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
停滞
技术栈
typescript
领域
documentation

调研方向

从链接的 TypeScript Handbook 类型兼容性页面开始,找到描述重载兼容性的部分。将其中的措辞与提供的赋值示例进行比较,然后更新源文档,使源类型和目标类型得到一致的描述。验证渲染后的页面以及示例所声明的行为。

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

描述

Docs

Search Terms: functions with overloads, type compatibility

In the docs, it says: "When a function has overloads, each overload in the source type must be matched by a compatible signature on the target type." But it should be "When a function has overloads, each overload in the source type target type must be matched by a compatible signature on the target type source type."

Code
The actual behaviour is right:

type t1 = {
    (foo: string): string
    (foo: number): number
}

type t2 = {
    (foo: string): string
}

declare let v1: t1;
declare let v2: t2;
v2 = v1 // OK
v1 = v2 // Error

The type on the right side of = is considered "the source type".

主要语言
Go
星标
111k
派生
14.4k
平均合并
1 天 15 小时
30 天内合并 PR
106

贡献指南

打开贡献指南

从这里开始

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

microsoft/TypeScript 的其他 Issue

查看 microsoft/TypeScript 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

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