Skip to content

Commit

Permalink
type: 完善 properties 类型推断
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhonghe committed May 30, 2022
1 parent f972da4 commit edaa402
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type ComputedOptions<
TWatch extends Record<string, (...args: any[]) => void>,
TComputed extends Record<
string,
(data: TData & { [K in keyof TProperty]: any }) => any
(data: TData & WechatMiniprogram.Component.PropertyOptionToData<TProperty>) => any
>,
TCustomInstanceProperty extends WechatMiniprogram.IAnyObject = {},
> = (Partial<WechatMiniprogram.Component.Data<TData>> &
Expand Down Expand Up @@ -48,7 +48,7 @@ export function ComponentWithComputed<
TWatch extends Record<string, (...args: any[]) => void>,
TComputed extends Record<
string,
(data: TData & { [K in keyof TProperty]: any }) => any
(data: TData & WechatMiniprogram.Component.PropertyOptionToData<TProperty>) => any
>,
TCustomInstanceProperty extends WechatMiniprogram.IAnyObject = {},
>(
Expand All @@ -75,7 +75,7 @@ export function BehaviorWithComputed<
TWatch extends Record<string, (...args: any[]) => void>,
TComputed extends Record<
string,
(data: TData & { [K in keyof TProperty]: any }) => any
(data: TData & WechatMiniprogram.Component.PropertyOptionToData<TProperty>) => any
>,
TCustomInstanceProperty extends WechatMiniprogram.IAnyObject = {},
>(
Expand Down
18 changes: 9 additions & 9 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ declare type ComputedInstance<D extends WechatMiniprogram.Component.DataOption,
[K in keyof P]: any;
};
};
declare type ComputedOptions<TData extends WechatMiniprogram.Component.DataOption, TProperty extends WechatMiniprogram.Component.PropertyOption, TMethod extends WechatMiniprogram.Component.MethodOption, TWatch extends Record<string, (...args: any[]) => void>, TComputed extends Record<string, (data: TData & {
[K in keyof TProperty]: any;
}) => any>, TCustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}> = (Partial<WechatMiniprogram.Component.Data<TData>> & Partial<WechatMiniprogram.Component.Property<TProperty>> & Partial<WechatMiniprogram.Component.Method<TMethod>> & Partial<WechatMiniprogram.Component.OtherOption> & Partial<WechatMiniprogram.Component.Lifetimes> & {
declare type ComputedOptions<TData extends WechatMiniprogram.Component.DataOption, TProperty extends WechatMiniprogram.Component.PropertyOption, TMethod extends WechatMiniprogram.Component.MethodOption, TWatch extends Record<string, (...args: any[]) => void>, TComputed extends Record<string, (
data: TData & WechatMiniprogram.Component.PropertyOptionToData<TProperty>
) => any>, TCustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}> = (Partial<WechatMiniprogram.Component.Data<TData>> & Partial<WechatMiniprogram.Component.Property<TProperty>> & Partial<WechatMiniprogram.Component.Method<TMethod>> & Partial<WechatMiniprogram.Component.OtherOption> & Partial<WechatMiniprogram.Component.Lifetimes> & {
watch?: TWatch;
computed?: TComputed;
template?: string;
}) & ThisType<ComputedInstance<TData, TProperty, TMethod, TComputed, TCustomInstanceProperty>>;
export declare function ComponentWithComputed<TData extends WechatMiniprogram.Component.DataOption, TProperty extends WechatMiniprogram.Component.PropertyOption, TMethod extends WechatMiniprogram.Component.MethodOption, TWatch extends Record<string, (...args: any[]) => void>, TComputed extends Record<string, (data: TData & {
[K in keyof TProperty]: any;
}) => any>, TCustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}>(options: ComputedOptions<TData, TProperty, TMethod, TWatch, TComputed, TCustomInstanceProperty>): string;
export declare function BehaviorWithComputed<TData extends WechatMiniprogram.Behavior.DataOption, TProperty extends WechatMiniprogram.Behavior.PropertyOption, TMethod extends WechatMiniprogram.Behavior.MethodOption, TWatch extends Record<string, (...args: any[]) => void>, TComputed extends Record<string, (data: TData & {
[K in keyof TProperty]: any;
}) => any>, TCustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}>(options: ComputedOptions<TData, TProperty, TMethod, TWatch, TComputed, TCustomInstanceProperty>): string;
export declare function ComponentWithComputed<TData extends WechatMiniprogram.Component.DataOption, TProperty extends WechatMiniprogram.Component.PropertyOption, TMethod extends WechatMiniprogram.Component.MethodOption, TWatch extends Record<string, (...args: any[]) => void>, TComputed extends Record<string, (
data: TData & WechatMiniprogram.Component.PropertyOptionToData<TProperty>
) => any>, TCustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}>(options: ComputedOptions<TData, TProperty, TMethod, TWatch, TComputed, TCustomInstanceProperty>): string;
export declare function BehaviorWithComputed<TData extends WechatMiniprogram.Behavior.DataOption, TProperty extends WechatMiniprogram.Behavior.PropertyOption, TMethod extends WechatMiniprogram.Behavior.MethodOption, TWatch extends Record<string, (...args: any[]) => void>, TComputed extends Record<string, (
data: TData & WechatMiniprogram.Component.PropertyOptionToData<TProperty>
) => any>, TCustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}>(options: ComputedOptions<TData, TProperty, TMethod, TWatch, TComputed, TCustomInstanceProperty>): string;
export declare enum DataTracerMode {
Auto = 0,
Proxy = 1,
Expand Down

0 comments on commit edaa402

Please sign in to comment.