admin管理员组文章数量:1130349
Property ‘zeroValue’ has no initializer and is not definitely assigned in the constructor.
Property ‘add’ has no initializer and is not definitely assigned in the constructor.
解决方法一
TypeScript的新特性所有定义的值必须赋予,初始值
我们设置其值 是可选
zeroValue?: T;
add?: (x: T, y: T) => T
解决方法二
创建构造方法
constructor(zeroValue: T) {
this.zeroValue = zeroValue
}
Property ‘zeroValue’ has no initializer and is not definitely assigned in the constructor.
Property ‘add’ has no initializer and is not definitely assigned in the constructor.
解决方法一
TypeScript的新特性所有定义的值必须赋予,初始值
我们设置其值 是可选
zeroValue?: T;
add?: (x: T, y: T) => T
解决方法二
创建构造方法
constructor(zeroValue: T) {
this.zeroValue = zeroValue
}
本文标签: 报错Typescript泛型类
版权声明:本文标题:TypeScript创建泛型类报错(泛型类) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/jiaocheng/1758620994a2781999.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论