microsoft / microsoft/TypeScript
Inconsistencies in assignability rules around top-level-like signatures
未关闭
还没有人认领这个 Issue。
Cursed?
Domain: check: Variance Relationships
Help Wanted
Possible Improvement
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
🔎 Search Terms
assignability any never signature
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
// source assignable to the target
const target1: (...args: any) => any = (...args: never) => 'foo'
// same source, but target now has *identical* return type as the source and all of a sudden it fails
const target2: (...args: any) => 'foo' = (...args: never) => 'foo'
// similar issue, target has the same return as in `target1` (any) but this time both source and target have **identical** extra leading parameter and it fails
const target3: (arg: unknown, ...args: any) => any = (arg: unknown, ...args: never) => 'foo'
// similar issue, target has the same return as in `target1` (any) but this time both source and target have **identical** `this` parameter and it fails
const target4: (this: unknown, ...args: any) => any = function (this: unknown, ...args: never) { return "foo"; };
🙁 Actual behavior
Assignability rules behave weirdly/inconsistently in those simple examples
🙂 Expected behavior
I'd expect more consistent results
Additional information about the issue
relates to https://github.com/microsoft/TypeScript/issues/55667 - the fact examples 2-4 error is the reason why that issue exists
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在链接的 TypeScript Playground 中重现四个赋值,并比较它们的可赋值性结果,包括相关 issue #55667。没有指定源文件或测试,也没有说明预期的一致规则;要取得进展,需要先确定哪些结果是正确的,然后再识别 checker 的入口点并添加有针对性的覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100