microsoft / microsoft/TypeScript
Function should be assignable to (...args: any[]) => any
未关闭
还没有人认领这个 Issue。
In Discussion
Suggestion
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
Obviously all functions have type Function. And likewise all functions can be given the type
type AnyFunc = (...args: any[]) => any;
AFAIK, there is nothing one can do with something of type Function that cannot be done with something of type AnyFunc and vice versa. However they are not equivalently assignable:
(f: AnyFunc): Function => f;
(f: Function): AnyFunc => f;
// ^
// Type 'Function' is not assignable to type 'AnyFunc'.
// Type 'Function' provides no match for the signature '(...args: any[]): any'.
If I edit lib.d.ts to add a callable signature to Function:
interface Function {
(...argArray: any[]): any;
//...
}
it seems to "fix" this issue; is there any reason not to make this change for real?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先检查 lib.d.ts 中的 Function 声明以及 issue 中展示的可赋值行为。调查 Function 和可调用签名的现有测试,然后评估添加该签名是否会保留类型系统的预期行为。当已针对演示的案例覆盖并处理所提议的可赋值性,且所有兼容性问题都已解决时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100