Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/didi/mpx
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyuki committed Sep 27, 2023
2 parents 6e496a5 + bbc7d6a commit 3861b1b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions packages/core/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,22 @@ type ArrayType<T extends any[]> = T extends Array<infer R> ? R : never;
// Mpx types
type Data = object | (() => object)

type PropType = StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor | null
type PropConstructor<T = any> = {
new (...args: any[]): T & {};
} | {
(): T;
}

interface PropOpt {
type: PropType
optionalTypes?: Array<PropType>
value?: any
export type PropType<T> = PropConstructor<T>

observer? (value: any, old: any, changedPath: string): void
type FullPropType<T> = {
type: PropType<T>;
value?: T;
optionalTypes?: PropType<T>[];
}

interface Properties {
[key: string]: WechatMiniprogram.Component.AllProperty
[key: string]: WechatMiniprogram.Component.AllProperty | PropType<any> | FullPropType<any>
}

interface Methods {
Expand Down Expand Up @@ -78,8 +82,12 @@ type PropValueType<Def> = Def extends {
}
? T
: Def extends (...args: any[]) => infer T
? T
: any;
? T
: Def extends FullPropType<infer T>
? T
: Def extends PropType<infer T>
? T
: any;

type GetPropsType<T> = {
readonly [K in keyof T]: PropValueType<T[K]>
Expand Down

0 comments on commit 3861b1b

Please sign in to comment.