File tree Expand file tree Collapse file tree 2 files changed +0
-7
lines changed
Expand file tree Collapse file tree 2 files changed +0
-7
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,6 @@ SOFTWARE.
2121***************************************************************************** */
2222
2323declare namespace WechatMiniprogram . Behavior {
24- // 为了支持 Behavior TS类型推导,必须得把 data、property、method 都暴露给 Component
25- // Behavior 实际返回的类型是 string。
2624 type BehaviorIdentifier <
2725 TData extends DataOption = { } ,
2826 TProperty extends PropertyOption = { } ,
@@ -71,7 +69,6 @@ declare namespace WechatMiniprogram.Behavior {
7169
7270 type DefinitionFilter = Component . DefinitionFilter
7371 type Lifetimes = Component . Lifetimes
74- // Behavior 中还能再用 behaviors,感觉这样代码组织很怪异的样子,这里需要类型支持?暂时没有支持
7572 type OtherOption = Omit < Component . OtherOption , 'options' > & { behaviors : BehaviorIdentifier [ ] }
7673}
7774/** 注册一个 `behavior`,接受一个 `Object` 类型的参数。*/
Original file line number Diff line number Diff line change @@ -98,14 +98,11 @@ declare namespace WechatMiniprogram.Component {
9898 type MethodOption = Record < string , Function >
9999
100100
101- /** 支持 Behavior 开始 */
102101 type BehaviorOption = Behavior . BehaviorIdentifier [ ]
103102 type ExtractData < T > = T extends { data : infer D } ? D : never
104103 type ExtractProperties < T > = T extends { properties : infer P } ? PropertyOptionToData < P extends PropertyOption ? P : { } > : never
105104 type ExtractMethods < T > = T extends { methods : infer M } ? M : never
106- // 联合类型转交叉类型
107105 type UnionToIntersection < U > = ( U extends any ? ( k : U ) => void : never ) extends ( k : infer I ) => void ? I : never
108-
109106 type MixinData < T extends any [ ] > = UnionToIntersection < ExtractData < T [ number ] > >
110107 type MixinProperties < T extends any [ ] > = UnionToIntersection < ExtractProperties < T [ number ] > >
111108 type MixinMethods < T extends any [ ] > = UnionToIntersection < ExtractMethods < T [ number ] > >
@@ -114,7 +111,6 @@ declare namespace WechatMiniprogram.Component {
114111 /** 类似于mixins和traits的组件间代码复用机制,参见 [behaviors](https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/behaviors.html) */
115112 behaviors ?: B
116113 }
117- /** 支持 Behavior 结束 */
118114
119115 interface Data < D extends DataOption > {
120116 /** 组件的内部数据,和 `properties` 一同用于组件的模板渲染 */
You can’t perform that action at this time.
0 commit comments