microsoft / microsoft/TypeScript
Generic Type constraint from base classes, interfaces (Pass through)
未关闭
还没有人认领这个 Issue。
Awaiting More Feedback
Suggestion
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 117
描述
The ability to allow extends type constraint to be an abstract specification of base class, interface.
This also prevent duplication, by having to define the type constraint twice, reduces the need for unnecessary intermediate interfaces.
type ID = string
interface IShape<TID extends ID, Neasted>{
__ID: TID;
__Neasted : Neasted
}
interface ITSShape<T, ID>
{
__tsType: T;
__ID: ID;
}
interface IShapeType extends IShape<'T', boolean | number | null>
{
}
Not possible
interface IShapeTSType<T extends ['__Neasted']> extends IShapeType
{
__tsType : T;
}
interface IShapeTSType<T extends ['__Neasted']> extends IShape<'T', boolean | number | string>
{
__tsType : T;
}
interface IShapeTSType<T extends this['__Neasted']> extends IShapeType
{
__tsType : T;
}
interface IShapeTSType<T extends TShape['__Neasted'], TShape extends IShapeType> extends TShape
{
__tsType : T;
}
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先分析提议的 IShape、IShapeType 和 IShapeTSType 示例,以明确预期的泛型约束和继承语义。定义应接受哪些语法,并验证其在不改变 JavaScript 输出的情况下避免重复约束;该 issue 未指定任何实现文件或测试。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100