glyphix 1.0.30 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/types/index.d.ts +20 -35
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -21,39 +21,31 @@ declare global {
|
|
|
21
21
|
function $t(key: string): string;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
type Data<T extends Record<string, any> = Record<string, any>> = T;
|
|
26
|
-
|
|
27
|
-
// 其他类型定义保持不变
|
|
28
|
-
type ComputedResults<C, D extends Data> = {
|
|
24
|
+
type ComputedResults<C, D> = {
|
|
29
25
|
readonly [K in keyof C as C[K] extends (this: D) => any
|
|
30
26
|
? K
|
|
31
27
|
: never]: C[K] extends () => infer R ? R : never;
|
|
32
28
|
} & {
|
|
33
29
|
[K in keyof C]: C[K] extends ComputedField<infer R> ? R : never;
|
|
34
30
|
};
|
|
35
|
-
|
|
36
31
|
type ComputedField<T> =
|
|
37
32
|
| {
|
|
38
33
|
get(): T;
|
|
39
34
|
set(x: T): void;
|
|
40
35
|
}
|
|
41
36
|
| (() => T);
|
|
42
|
-
|
|
43
|
-
type Computed<C, D
|
|
37
|
+
type Data = Record<string, any>;
|
|
38
|
+
type Computed<C, D> = {
|
|
44
39
|
[K in keyof C]: K extends keyof D ? never : ComputedField<C[K]>;
|
|
45
40
|
} & ThisType<D>;
|
|
46
|
-
|
|
47
41
|
type Watches<W, D extends Data> = {
|
|
48
42
|
[K in keyof W]: K extends keyof D
|
|
49
43
|
? ((newValue: D[K], oldValue: D[K]) => void) | undefined
|
|
50
|
-
:
|
|
44
|
+
: never;
|
|
51
45
|
};
|
|
52
|
-
|
|
53
|
-
type Methods<M, D extends Data> = {
|
|
46
|
+
type Methods<M, D> = {
|
|
54
47
|
[K in keyof M]: K extends keyof D ? never : M[K];
|
|
55
48
|
};
|
|
56
|
-
|
|
57
49
|
type LifeCycleHooks = {
|
|
58
50
|
onInit?: () => void;
|
|
59
51
|
onReady?: () => void;
|
|
@@ -61,7 +53,6 @@ type LifeCycleHooks = {
|
|
|
61
53
|
onHide?: () => void;
|
|
62
54
|
onDestroy?: () => void;
|
|
63
55
|
};
|
|
64
|
-
|
|
65
56
|
type OmitedProps =
|
|
66
57
|
| "data"
|
|
67
58
|
| "computed"
|
|
@@ -70,7 +61,6 @@ type OmitedProps =
|
|
|
70
61
|
| "onShow"
|
|
71
62
|
| "onHide"
|
|
72
63
|
| "onDestroy";
|
|
73
|
-
|
|
74
64
|
type ComponentInternals = {
|
|
75
65
|
$element(id: string): Record<string, any> | undefined;
|
|
76
66
|
$valid: boolean;
|
|
@@ -79,31 +69,26 @@ type ComponentInternals = {
|
|
|
79
69
|
$component(name: string, url: string): void;
|
|
80
70
|
$emit(name: string, ...args: Array<any>);
|
|
81
71
|
};
|
|
82
|
-
|
|
83
|
-
type ComponentProps<D extends Data, C, M> = Omit<
|
|
72
|
+
type ComponentProps<D, C, M> = Omit<
|
|
84
73
|
D & ComputedResults<C, D> & M & ComponentInternals,
|
|
85
74
|
OmitedProps
|
|
86
75
|
>;
|
|
87
|
-
|
|
88
|
-
// 修正 ComponentOptions 类型
|
|
89
76
|
type ComponentOptions<
|
|
90
|
-
|
|
91
|
-
C
|
|
92
|
-
W
|
|
93
|
-
M
|
|
77
|
+
D extends Data,
|
|
78
|
+
C, // 先不深究 C 的 this 约束
|
|
79
|
+
W,
|
|
80
|
+
M
|
|
94
81
|
> = {
|
|
95
|
-
data:
|
|
96
|
-
computed?: Computed<C,
|
|
97
|
-
watch?: Watches<W,
|
|
82
|
+
data: D;
|
|
83
|
+
computed?: Computed<C, D>;
|
|
84
|
+
watch?: Watches<W, D>;
|
|
98
85
|
} & LifeCycleHooks &
|
|
99
|
-
Methods<M,
|
|
100
|
-
ThisType<ComponentProps<
|
|
101
|
-
|
|
86
|
+
Methods<M, D> &
|
|
87
|
+
ThisType<ComponentProps<D, Computed<C, D & Methods<M, D>>, M>>;
|
|
102
88
|
export declare function defineComponent<
|
|
103
|
-
|
|
104
|
-
C
|
|
105
|
-
W
|
|
106
|
-
M
|
|
107
|
-
>(options: ComponentOptions<
|
|
108
|
-
|
|
89
|
+
D extends Data,
|
|
90
|
+
C, // 计算属性可能依赖于 data 和 methods
|
|
91
|
+
W,
|
|
92
|
+
M
|
|
93
|
+
>(options: ComponentOptions<D, C, W, M>): ComponentOptions<D, C, W, M>;
|
|
109
94
|
export {};
|