Skip to content

Commit

Permalink
chore: resolve conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
lv-z-l committed Sep 12, 2024
1 parent 57d4c82 commit e940cb8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion test/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ Component({
},
})

Component<{}, {}, { fn(): void }>({
Component<{}, {}, { fn(): void }, []>({
methods: {
fn() {
expectError(this.notExists)
Expand Down
2 changes: 1 addition & 1 deletion test/computed.test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ declare namespace WechatMiniprogram {
CustomProperty extends IAnyObject = Record<string, never>,
> = Partial<Computed<C>> &
ThisType<ComputedInstance<D, P, M, C, CustomProperty>> &
Options<D, P, M>
Options<D, P, M, []>
interface ComputedConstructor {
<
D extends DataOption,
Expand Down
2 changes: 1 addition & 1 deletion test/issue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ wx.request({
f?: () => string
g: () => void
}
type Dialog = WechatMiniprogram.Component.Instance<{}, {}, IDialogMethod>
type Dialog = WechatMiniprogram.Component.Instance<{}, {}, IDialogMethod, []>
Page({
f() {
const comp = this.selectComponent('#comp') as Dialog
Expand Down
13 changes: 6 additions & 7 deletions types/wx/lib.wx.behavior.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,28 @@ SOFTWARE.
***************************************************************************** */

declare namespace WechatMiniprogram.Behavior {
type RealBehaviorType<

type BehaviorIdentifier<
TData extends DataOption = {},
TProperty extends PropertyOption = {},
TMethod extends MethodOption = {},
TBehavior extends BehaviorOption = []
> = {
> = string & {
[key in 'BehaviorType']?: {
data: TData & Component.MixinData<TBehavior>
properties: TProperty & Component.MixinProperties<TBehavior, true>
methods: TMethod & Component.MixinMethods<TBehavior>
}
}

type BehaviorIdentifier = string
type Instance<
TData extends DataOption,
TProperty extends PropertyOption,
TMethod extends MethodOption,
TBehavior extends BehaviorOption,
TCustomInstanceProperty extends IAnyObject = Record<string, never>
> = Component.Instance<TData, TProperty, TMethod, TBehavior, TCustomInstanceProperty>
type TrivialInstance = Instance<IAnyObject, IAnyObject, IAnyObject, Component.IAnyArray>
type TrivialOption = Options<IAnyObject, IAnyObject, IAnyObject, Component.IAnyArray>
type TrivialInstance = Instance<IAnyObject, IAnyObject, IAnyObject, Component.IEmptyArray>
type TrivialOption = Options<IAnyObject, IAnyObject, IAnyObject, Component.IEmptyArray>
type Options<
TData extends DataOption,
TProperty extends PropertyOption,
Expand All @@ -66,7 +65,7 @@ declare namespace WechatMiniprogram.Behavior {
TCustomInstanceProperty extends IAnyObject = Record<string, never>
>(
options: Options<TData, TProperty, TMethod, TBehavior, TCustomInstanceProperty>
): BehaviorIdentifier & RealBehaviorType<TData, TProperty, TMethod, TBehavior>
): BehaviorIdentifier<TData, TProperty, TMethod, TBehavior>
}

type DataOption = Component.DataOption
Expand Down
13 changes: 7 additions & 6 deletions types/wx/lib.wx.component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare namespace WechatMiniprogram.Component {
TData extends DataOption,
TProperty extends PropertyOption,
TMethod extends Partial<MethodOption>,
TBehavior extends BehaviorOption = [],
TBehavior extends BehaviorOption,
TCustomInstanceProperty extends IAnyObject = {},
TIsPage extends boolean = false
> = InstanceProperties &
Expand All @@ -35,27 +35,28 @@ declare namespace WechatMiniprogram.Component {
MixinMethods<TBehavior> &
(TIsPage extends true ? Page.ILifetime : {}) &
Omit<TCustomInstanceProperty, 'properties' | 'methods' | 'data'> & {
/** 组件数据,**包括内部数据和属性值** */
data: TData & MixinData<TBehavior> &
MixinProperties<TBehavior> & PropertyOptionToData<FilterUnknownProperty<TProperty>>
/** 组件数据,**包括内部数据和属性值**(与 `data` 一致) */
properties: TData & MixinData<TBehavior> &
MixinProperties<TBehavior> & PropertyOptionToData<FilterUnknownProperty<TProperty>>
}

type IAnyArray = []
type IEmptyArray = []
type TrivialInstance = Instance<
IAnyObject,
IAnyObject,
IAnyObject,
IAnyArray,
IEmptyArray,
IAnyObject
>
type TrivialOption = Options<IAnyObject, IAnyObject, IAnyObject, IAnyArray, IAnyObject>
type TrivialOption = Options<IAnyObject, IAnyObject, IAnyObject, IEmptyArray, IAnyObject>
type Options<
TData extends DataOption,
TProperty extends PropertyOption,
TMethod extends MethodOption,
TBehavior extends BehaviorOption = [],
TBehavior extends BehaviorOption,
TCustomInstanceProperty extends IAnyObject = {},
TIsPage extends boolean = false
> = Partial<Data<TData>> &
Expand All @@ -79,7 +80,7 @@ declare namespace WechatMiniprogram.Component {
TData extends DataOption,
TProperty extends PropertyOption,
TMethod extends MethodOption,
TBehavior extends BehaviorOption = [],
TBehavior extends BehaviorOption,
TCustomInstanceProperty extends IAnyObject = {},
TIsPage extends boolean = false
>(
Expand Down

0 comments on commit e940cb8

Please sign in to comment.