api-typings
api-typings copied to clipboard
[feat] wx.component.d.ts 可以支持自定义根属性扩展
我给 component
options里扩展了一个属性选项computed,我需要给它编写类型定义, 场景:
Component({
computed: {
sum(data) {
return 1;
}
}
});
但是发现并没有提供相关扩展:
https://github.com/wechat-miniprogram/api-typings/blob/c7fb54c1274f2827aa7852071a4a1813aa9fcea2/types/wx/lib.wx.component.d.ts#L47
但是Page是提供了CustomOption
来方便用户进行自定义属性值或者函数扩展的:
https://github.com/wechat-miniprogram/api-typings/blob/c7fb54c1274f2827aa7852071a4a1813aa9fcea2/types/wx/lib.wx.page.d.ts#L39
希望能和Page一样提供一下自定义扩展类型
我可以帮忙改进一下,不过得等我年底考完研
和 Page
不同的是挂在 Component
构造器上的自定义属性是不能通过 this.computed
来获取的,所以当时没有做这个自定义根属性;实际上单纯支持这个的话,computed
的类型也没法推出来的,computed
的例子可以参考 https://github.com/wechat-miniprogram/api-typings/blob/master/test/computed.test.d.ts
(怎么搞 behaviors
带来的类型变动的问题我们也在想办法,不过似乎目前没有比较好的解决方案😂
behaviors 基本是无解的,今天我尝试重构一下 component