annil 1.6.1 → 1.6.2
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/CHANGELOG.md +7 -0
- package/dist/api/DefineComponent/assignOptions/index.js +0 -8
- package/dist/api/DefineComponent/assignOptions/index.js.map +1 -1
- package/dist/api/InstanceInject/instanceConfig.d.ts +5 -2
- package/dist/api/InstanceInject/instanceConfig.js.map +1 -1
- package/dist/api/RootComponent/Instance/RootComponentInstance.d.ts +3 -6
- package/dist/api/RootComponent/Observers/ObserversOption.d.ts +2 -3
- package/dist/api/RootComponent/Watch/WatchOption.d.ts +2 -3
- package/dist/api/RootComponent/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/api/DefineComponent/assignOptions/index.ts +12 -12
- package/src/api/InstanceInject/instanceConfig.ts +11 -2
- package/src/api/RootComponent/Computed/test/normal.test.ts +16 -16
- package/src/api/RootComponent/CustomEvents/test/normal.test.ts +0 -19
- package/src/api/RootComponent/Data/test/normal.test.ts +5 -36
- package/src/api/RootComponent/Instance/RootComponentInstance.ts +4 -5
- package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +9 -4
- package/src/api/RootComponent/Observers/ObserversOption.ts +8 -11
- package/src/api/RootComponent/Observers/test/normal.test.ts +2 -3
- package/src/api/RootComponent/Properties/test/normalEmpty.test.ts +5 -6
- package/src/api/RootComponent/Properties/test/normalOptional.test.ts +4 -4
- package/src/api/RootComponent/Properties/test/normalRequired.test.ts +4 -4
- package/src/api/RootComponent/Watch/WatchOption.ts +17 -23
- package/src/api/RootComponent/Watch/test/WatchComputed.test.ts +4 -4
- package/src/api/RootComponent/Watch/test/WatchData.test.ts +4 -5
- package/src/api/RootComponent/Watch/test/WatchProperties.test.ts +13 -23
- package/src/api/RootComponent/index.ts +2 -2
- package/src/api/SubComponent/SubComputed/test/normal.test.ts +6 -6
- package/src/api/SubComponent/SubData/test/normal.test.ts +5 -5
- package/src/api/SubComponent/SubInstance/test/normal.test.ts +4 -4
- package/src/api/SubComponent/SubWatch/test/WatchProperties.test.ts +13 -23
- package/src/api/SubComponent/SubWatch/test/WatchRootData.test.ts +10 -11
- package/src/api/RootComponent/Instance/test/cloneData/error.test.ts +0 -31
- package/src/api/RootComponent/Instance/test/cloneData/normal.test.ts +0 -53
- package/src/api/SubComponent/SubInstance/test/cloneData/error.test.ts +0 -22
- package/src/api/SubComponent/SubInstance/test/cloneData/normal.test.ts +0 -73
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
2
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
3
2
|
import type { IsPureObject } from "hry-types/src/Any/IsPureObject";
|
|
4
3
|
import type { NoInfer } from "hry-types/src/Generic/NoInfer";
|
|
@@ -20,27 +19,22 @@ type AddFieldsOfObject<
|
|
|
20
19
|
> = {
|
|
21
20
|
[k in secondKeys]?: (
|
|
22
21
|
// @ts-ignore
|
|
23
|
-
newValue:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
NonNullable<(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]>
|
|
31
|
-
>
|
|
22
|
+
newValue: IfExtends<
|
|
23
|
+
getLastKeys<k>,
|
|
24
|
+
"**",
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
Exclude<TWatchData[getFirstKeys<k>], null>,
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
NonNullable<(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]>
|
|
32
29
|
>,
|
|
33
|
-
oldValue:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]
|
|
41
|
-
>
|
|
30
|
+
oldValue: IfExtends<
|
|
31
|
+
getLastKeys<k>,
|
|
32
|
+
"**",
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
TWatchData[getFirstKeys<k>],
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]
|
|
42
37
|
>,
|
|
43
|
-
// ReadonlyDeep<(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]>,
|
|
44
38
|
) => void;
|
|
45
39
|
};
|
|
46
40
|
|
|
@@ -57,9 +51,9 @@ export type WatchOption<TWatchData extends object, _WatchKeys extends keyof TWat
|
|
|
57
51
|
NoInfer<
|
|
58
52
|
& {
|
|
59
53
|
[k in _WatchKeys]?: (
|
|
60
|
-
// newValue 去除null
|
|
61
|
-
newValue:
|
|
62
|
-
oldValue:
|
|
54
|
+
// newValue 去除null
|
|
55
|
+
newValue: Exclude<TWatchData[k], null>,
|
|
56
|
+
oldValue: TWatchData[k],
|
|
63
57
|
) => void;
|
|
64
58
|
}
|
|
65
59
|
// 解决单独书写计算书写字段的报错(猜测是:ts字面量约束检测提前计算属性key引起的错误提示)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import type { DetailedType } from "../../../../types/DetailedType";
|
|
4
4
|
import { RootComponent } from "../..";
|
|
5
5
|
import type { Mock_User } from "../../Properties/test/normalRequired.test";
|
|
@@ -29,10 +29,10 @@ RootComponent()({
|
|
|
29
29
|
|
|
30
30
|
Checking<number, typeof oldValue, Test.Pass>;
|
|
31
31
|
},
|
|
32
|
-
Cobj(newValue:
|
|
33
|
-
Checking<
|
|
32
|
+
Cobj(newValue: Mock_User, oldValue: Mock_User | null) {
|
|
33
|
+
Checking<Mock_User, typeof newValue, Test.Pass>;
|
|
34
34
|
|
|
35
|
-
Checking<
|
|
35
|
+
Checking<Mock_User | null, typeof oldValue, Test.Pass>;
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
38
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
2
|
|
|
3
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
4
3
|
import { observable } from "mobx";
|
|
5
4
|
import { RootComponent } from "../..";
|
|
6
5
|
import type { Mock_User } from "../../Properties/test/normalRequired.test";
|
|
@@ -29,9 +28,9 @@ RootComponent()({
|
|
|
29
28
|
Checking<number, typeof oldValue, Test.Pass>;
|
|
30
29
|
},
|
|
31
30
|
obj(newValue, oldValue) {
|
|
32
|
-
Checking<
|
|
31
|
+
Checking<Mock_User, typeof newValue, Test.Pass>;
|
|
33
32
|
|
|
34
|
-
Checking<
|
|
33
|
+
Checking<Mock_User, typeof oldValue, Test.Pass>;
|
|
35
34
|
},
|
|
36
35
|
reactiveNumber(newValue: number, oldValue) {
|
|
37
36
|
Checking<number, typeof newValue, Test.Pass>;
|
|
@@ -44,9 +43,9 @@ RootComponent()({
|
|
|
44
43
|
Checking<"male" | "female", typeof oldValue, Test.Pass>;
|
|
45
44
|
},
|
|
46
45
|
reactiveUser(newValue, oldValue) {
|
|
47
|
-
Checking<
|
|
46
|
+
Checking<Mock_User, typeof newValue, Test.Pass>;
|
|
48
47
|
|
|
49
|
-
Checking<
|
|
48
|
+
Checking<Mock_User, typeof oldValue, Test.Pass>;
|
|
50
49
|
},
|
|
51
50
|
},
|
|
52
51
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import type { DetailedType } from "../../../..";
|
|
4
4
|
import { RootComponent } from "../..";
|
|
5
5
|
import type { OptionalType } from "../../Properties/PropertiesConstraint";
|
|
@@ -58,26 +58,16 @@ RootComponent()({
|
|
|
58
58
|
|
|
59
59
|
Checking<boolean, typeof oldValue, Test.Pass>;
|
|
60
60
|
},
|
|
61
|
-
arr(newValue, oldValue) {
|
|
62
|
-
newValue; // readonly ReadonlyDeep<unknown>[]
|
|
63
|
-
|
|
64
|
-
oldValue; // readonly ReadonlyDeep<unknown>[]
|
|
65
61
|
|
|
66
|
-
// ts中很多不是错误的错误,写 typeof newValue 结果是错误
|
|
67
|
-
Checking<unknown[], typeof newValue, Test.Fail>;
|
|
68
|
-
|
|
69
|
-
// ts中很多不是错误的错误,写 readonly ReadonlyDeep<unknown>[] 结果是正确的
|
|
70
|
-
Checking<readonly unknown[], readonly ReadonlyDeep<unknown>[], Test.Pass>;
|
|
71
|
-
},
|
|
72
62
|
obj(newValue, oldValue) {
|
|
73
63
|
Checking<object, typeof newValue, Test.Pass>;
|
|
74
64
|
|
|
75
65
|
Checking<object | null, typeof oldValue, Test.Pass>;
|
|
76
66
|
},
|
|
77
67
|
tuple(newValue, oldValue) {
|
|
78
|
-
Checking<
|
|
68
|
+
Checking<[string, number, boolean], typeof newValue, Test.Pass>;
|
|
79
69
|
|
|
80
|
-
Checking<
|
|
70
|
+
Checking<[string, number, boolean], typeof oldValue, Test.Pass>;
|
|
81
71
|
},
|
|
82
72
|
union_str(newValue, oldValue) {
|
|
83
73
|
Checking<"male" | "female", typeof newValue, Test.Pass>;
|
|
@@ -95,14 +85,14 @@ RootComponent()({
|
|
|
95
85
|
Checking<false | true, typeof oldValue, Test.Pass>;
|
|
96
86
|
},
|
|
97
87
|
union_arr(newValue, oldValue) {
|
|
98
|
-
Checking<
|
|
88
|
+
Checking<number[] | string[], typeof newValue, Test.Pass>;
|
|
99
89
|
|
|
100
|
-
Checking<
|
|
90
|
+
Checking<number[] | string[], typeof oldValue, Test.Pass>;
|
|
101
91
|
},
|
|
102
92
|
union_obj(newValue, oldValue) {
|
|
103
|
-
Checking<
|
|
93
|
+
Checking<Mock_User | Mock_Cart, typeof newValue, Test.Pass>;
|
|
104
94
|
|
|
105
|
-
Checking<
|
|
95
|
+
Checking<Mock_User | Mock_Cart | null, typeof oldValue, Test.Pass>;
|
|
106
96
|
},
|
|
107
97
|
// 必传多类型联合
|
|
108
98
|
union_str_num_bool(newValue, oldValue) {
|
|
@@ -116,9 +106,9 @@ RootComponent()({
|
|
|
116
106
|
Checking<0 | 1 | 2 | "male" | "female", typeof oldValue, Test.Pass>;
|
|
117
107
|
},
|
|
118
108
|
union_mockUser_num(newValue, oldValue) {
|
|
119
|
-
Checking<
|
|
109
|
+
Checking<number | Mock_User, typeof newValue, Test.Pass>;
|
|
120
110
|
|
|
121
|
-
Checking<
|
|
111
|
+
Checking<number | Mock_User | null, typeof oldValue, Test.Pass>;
|
|
122
112
|
},
|
|
123
113
|
// 可选字段
|
|
124
114
|
optional_gender(newValue, oldValue) {
|
|
@@ -132,9 +122,9 @@ RootComponent()({
|
|
|
132
122
|
Checking<number, typeof oldValue, Test.Pass>;
|
|
133
123
|
},
|
|
134
124
|
optional_obj(newValue, oldValue) {
|
|
135
|
-
Checking<
|
|
125
|
+
Checking<Mock_User, typeof newValue, Test.Pass>;
|
|
136
126
|
|
|
137
|
-
Checking<
|
|
127
|
+
Checking<Mock_User | null, typeof oldValue, Test.Pass>;
|
|
138
128
|
},
|
|
139
129
|
// 对象的二段key
|
|
140
130
|
"optional_obj.age"(newValue, oldValue) {
|
|
@@ -143,9 +133,9 @@ RootComponent()({
|
|
|
143
133
|
Checking<number | undefined, typeof oldValue, Test.Pass>;
|
|
144
134
|
},
|
|
145
135
|
"optional_obj.**"(newValue, oldValue) {
|
|
146
|
-
Checking<
|
|
136
|
+
Checking<Mock_User, typeof newValue, Test.Pass>;
|
|
147
137
|
|
|
148
|
-
Checking<
|
|
138
|
+
Checking<Mock_User | null, typeof oldValue, Test.Pass>;
|
|
149
139
|
},
|
|
150
140
|
"optional_obj.id"(newValue, oldValue) {
|
|
151
141
|
Checking<string, typeof newValue, Test.Pass>;
|
|
@@ -5,7 +5,7 @@ import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
|
5
5
|
import type { ComputeObject } from "../../types/ComputeObj";
|
|
6
6
|
import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
|
|
7
7
|
import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
8
|
-
import type {
|
|
8
|
+
import type { IInjectAllData, IInjectStore } from "../InstanceInject/instanceConfig";
|
|
9
9
|
import type { ComputedConstraint } from "./Computed/ComputedConstraint";
|
|
10
10
|
import type { ComputedOption } from "./Computed/ComputedOption";
|
|
11
11
|
import type { GetComputedDoc } from "./Computed/GetComputedDoc";
|
|
@@ -58,7 +58,7 @@ type RootComponentOptions<
|
|
|
58
58
|
& ComputedOption<
|
|
59
59
|
TComputed,
|
|
60
60
|
keyof (PropertiesDoc & DataDoc & StoreDoc),
|
|
61
|
-
{ data: ComputeObject<DataDoc & Required<PropertiesDoc> & StoreDoc & ComputedDoc &
|
|
61
|
+
{ data: ComputeObject<DataDoc & Required<PropertiesDoc> & StoreDoc & ComputedDoc & IInjectAllData> }
|
|
62
62
|
>
|
|
63
63
|
& PageLifetimesOption<TIsPage, PropertiesDoc>
|
|
64
64
|
& LifetimesOption
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
2
|
import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc";
|
|
4
3
|
|
|
5
|
-
import type {
|
|
4
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
5
|
+
import type { IInjectAllData } from "../../../InstanceInject/instanceConfig";
|
|
6
6
|
import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
|
|
7
7
|
import { SubComponent } from "../..";
|
|
8
8
|
|
|
@@ -81,7 +81,7 @@ SubComponent<Root, OnlyPropsCompDoc>()({
|
|
|
81
81
|
// 5 this.data
|
|
82
82
|
Checking<
|
|
83
83
|
typeof this.data,
|
|
84
|
-
|
|
84
|
+
ComputeIntersection<
|
|
85
85
|
{
|
|
86
86
|
num: number;
|
|
87
87
|
user: User | null;
|
|
@@ -92,7 +92,7 @@ SubComponent<Root, OnlyPropsCompDoc>()({
|
|
|
92
92
|
aaa_num123: 123;
|
|
93
93
|
aaa_str: "a" | "b";
|
|
94
94
|
aaa_obj: Mock_User | null;
|
|
95
|
-
} &
|
|
95
|
+
} & IInjectAllData
|
|
96
96
|
>,
|
|
97
97
|
Test.Pass
|
|
98
98
|
>;
|
|
@@ -105,7 +105,7 @@ SubComponent<Root, OnlyPropsCompDoc>()({
|
|
|
105
105
|
// 5 this.data 深度只读
|
|
106
106
|
Checking<
|
|
107
107
|
typeof this.data,
|
|
108
|
-
|
|
108
|
+
ComputeIntersection<
|
|
109
109
|
{
|
|
110
110
|
num: number;
|
|
111
111
|
user: User | null;
|
|
@@ -116,7 +116,7 @@ SubComponent<Root, OnlyPropsCompDoc>()({
|
|
|
116
116
|
aaa_num123: 123;
|
|
117
117
|
aaa_str: "a" | "b";
|
|
118
118
|
aaa_obj: Mock_User | null;
|
|
119
|
-
} &
|
|
119
|
+
} & IInjectAllData
|
|
120
120
|
>,
|
|
121
121
|
Test.Pass
|
|
122
122
|
>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
2
|
import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc";
|
|
4
3
|
|
|
5
|
-
import type {
|
|
4
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
5
|
+
import type { IInjectAllData } from "../../../InstanceInject/instanceConfig";
|
|
6
6
|
import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
|
|
7
7
|
import { SubComponent } from "../..";
|
|
8
8
|
|
|
@@ -51,13 +51,13 @@ SubComponent<{}, CompDoc>()({
|
|
|
51
51
|
// 4 this.data中的data配置数据
|
|
52
52
|
Checking<
|
|
53
53
|
typeof this.data,
|
|
54
|
-
|
|
54
|
+
ComputeIntersection<
|
|
55
55
|
{
|
|
56
56
|
_aaa_str: string;
|
|
57
57
|
aaa_str: "a" | "b";
|
|
58
58
|
aaa_num: number;
|
|
59
59
|
aaa_obj: Mock_User | null;
|
|
60
|
-
} &
|
|
60
|
+
} & IInjectAllData
|
|
61
61
|
>,
|
|
62
62
|
Test.Pass
|
|
63
63
|
>;
|
|
@@ -72,7 +72,7 @@ SubComponent<{ data: { _num: number } }, CompDoc>()({
|
|
|
72
72
|
},
|
|
73
73
|
lifetimes: {
|
|
74
74
|
attached() {
|
|
75
|
-
Checking<typeof this.data.aaa_obj,
|
|
75
|
+
Checking<typeof this.data.aaa_obj, Mock_User | null, Test.Pass>;
|
|
76
76
|
|
|
77
77
|
this.setData({
|
|
78
78
|
aaa_obj: {} as Mock_User, // aaa_obj 类型为 Mock_User | null 而非 null
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
2
|
import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc";
|
|
4
3
|
|
|
5
|
-
import type {
|
|
4
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
5
|
+
import type { IInjectAllData } from "../../../InstanceInject/instanceConfig";
|
|
6
6
|
import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
|
|
7
7
|
import type { RootComponentDoc } from "../../../RootComponent/RootComponentDoc";
|
|
8
8
|
import { SubComponent } from "../..";
|
|
@@ -55,7 +55,7 @@ SubComponent<RootDoc, CompDoc>()({
|
|
|
55
55
|
// this.data
|
|
56
56
|
Checking<
|
|
57
57
|
typeof this.data,
|
|
58
|
-
|
|
58
|
+
ComputeIntersection<
|
|
59
59
|
{
|
|
60
60
|
// RootData
|
|
61
61
|
Pstr: string;
|
|
@@ -65,7 +65,7 @@ SubComponent<RootDoc, CompDoc>()({
|
|
|
65
65
|
Cnum: number;
|
|
66
66
|
// 自身Data类型与CompDoc类型相同
|
|
67
67
|
aaa_str: string;
|
|
68
|
-
} &
|
|
68
|
+
} & IInjectAllData
|
|
69
69
|
>,
|
|
70
70
|
Test.Pass
|
|
71
71
|
>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { type DetailedType, RootComponent, SubComponent } from "../../../..";
|
|
4
4
|
import type { OptionalType } from "../../../RootComponent/Properties/PropertiesConstraint";
|
|
5
5
|
import {
|
|
@@ -63,26 +63,16 @@ SubComponent<Root, { properties: { aaa_num: number } }>()({
|
|
|
63
63
|
|
|
64
64
|
Checking<boolean, typeof oldValue, Test.Pass>;
|
|
65
65
|
},
|
|
66
|
-
arr(newValue, oldValue) {
|
|
67
|
-
newValue; // readonly ReadonlyDeep<unknown>[]
|
|
68
|
-
|
|
69
|
-
oldValue; // readonly ReadonlyDeep<unknown>[]
|
|
70
66
|
|
|
71
|
-
// ts中很多不是错误的错误,写 typeof newValue 结果是错误
|
|
72
|
-
Checking<unknown[], typeof newValue, Test.Fail>;
|
|
73
|
-
|
|
74
|
-
// ts中很多不是错误的错误,写 readonly ReadonlyDeep<unknown>[] 结果是正确的
|
|
75
|
-
Checking<readonly unknown[], readonly ReadonlyDeep<unknown>[], Test.Pass>;
|
|
76
|
-
},
|
|
77
67
|
obj(newValue, oldValue) {
|
|
78
68
|
Checking<object, typeof newValue, Test.Pass>;
|
|
79
69
|
|
|
80
70
|
Checking<object | null, typeof oldValue, Test.Pass>;
|
|
81
71
|
},
|
|
82
72
|
tuple(newValue, oldValue) {
|
|
83
|
-
Checking<
|
|
73
|
+
Checking<[string, number, boolean], typeof newValue, Test.Pass>;
|
|
84
74
|
|
|
85
|
-
Checking<
|
|
75
|
+
Checking<[string, number, boolean], typeof oldValue, Test.Pass>;
|
|
86
76
|
},
|
|
87
77
|
union_str(newValue, oldValue) {
|
|
88
78
|
Checking<"male" | "female", typeof newValue, Test.Pass>;
|
|
@@ -100,14 +90,14 @@ SubComponent<Root, { properties: { aaa_num: number } }>()({
|
|
|
100
90
|
Checking<false | true, typeof oldValue, Test.Pass>;
|
|
101
91
|
},
|
|
102
92
|
union_arr(newValue, oldValue) {
|
|
103
|
-
Checking<
|
|
93
|
+
Checking<number[] | string[], typeof newValue, Test.Pass>;
|
|
104
94
|
|
|
105
|
-
Checking<
|
|
95
|
+
Checking<number[] | string[], typeof oldValue, Test.Pass>;
|
|
106
96
|
},
|
|
107
97
|
union_obj(newValue, oldValue) {
|
|
108
|
-
Checking<
|
|
98
|
+
Checking<Mock_User | Mock_Cart, typeof newValue, Test.Pass>;
|
|
109
99
|
|
|
110
|
-
Checking<
|
|
100
|
+
Checking<Mock_User | Mock_Cart | null, typeof oldValue, Test.Pass>;
|
|
111
101
|
},
|
|
112
102
|
// 必传多类型联合
|
|
113
103
|
union_str_num_bool(newValue, oldValue) {
|
|
@@ -121,9 +111,9 @@ SubComponent<Root, { properties: { aaa_num: number } }>()({
|
|
|
121
111
|
Checking<0 | 1 | 2 | "male" | "female", typeof oldValue, Test.Pass>;
|
|
122
112
|
},
|
|
123
113
|
union_mockUser_num(newValue, oldValue) {
|
|
124
|
-
Checking<
|
|
114
|
+
Checking<number | Mock_User, typeof newValue, Test.Pass>;
|
|
125
115
|
|
|
126
|
-
Checking<
|
|
116
|
+
Checking<number | Mock_User | null, typeof oldValue, Test.Pass>;
|
|
127
117
|
},
|
|
128
118
|
// 可选字段
|
|
129
119
|
optional_gender(newValue, oldValue) {
|
|
@@ -137,9 +127,9 @@ SubComponent<Root, { properties: { aaa_num: number } }>()({
|
|
|
137
127
|
Checking<number, typeof oldValue, Test.Pass>;
|
|
138
128
|
},
|
|
139
129
|
optional_obj(newValue, oldValue) {
|
|
140
|
-
Checking<
|
|
130
|
+
Checking<Mock_User, typeof newValue, Test.Pass>;
|
|
141
131
|
|
|
142
|
-
Checking<
|
|
132
|
+
Checking<Mock_User | null, typeof oldValue, Test.Pass>;
|
|
143
133
|
},
|
|
144
134
|
// 对象的二段key
|
|
145
135
|
"optional_obj.age"(newValue, oldValue) {
|
|
@@ -148,9 +138,9 @@ SubComponent<Root, { properties: { aaa_num: number } }>()({
|
|
|
148
138
|
Checking<number | undefined, typeof oldValue, Test.Pass>;
|
|
149
139
|
},
|
|
150
140
|
"optional_obj.**"(newValue, oldValue) {
|
|
151
|
-
Checking<
|
|
141
|
+
Checking<Mock_User, typeof newValue, Test.Pass>;
|
|
152
142
|
|
|
153
|
-
Checking<
|
|
143
|
+
Checking<Mock_User | null, typeof oldValue, Test.Pass>;
|
|
154
144
|
},
|
|
155
145
|
"optional_obj.id"(newValue, oldValue) {
|
|
156
146
|
Checking<string, typeof newValue, Test.Pass>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
2
|
|
|
3
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
4
3
|
import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc";
|
|
5
4
|
|
|
6
5
|
import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
|
|
@@ -66,24 +65,24 @@ SubComponent<RootDoc, CompDoc>()({
|
|
|
66
65
|
Checking<string | number, typeof oldValue, Test.Pass>;
|
|
67
66
|
},
|
|
68
67
|
required_obj(newValue, oldValue) {
|
|
69
|
-
Checking<
|
|
68
|
+
Checking<Mock_User, typeof newValue, Test.Pass>;
|
|
70
69
|
|
|
71
|
-
Checking<
|
|
70
|
+
Checking<Mock_User | null, typeof oldValue, Test.Pass>;
|
|
72
71
|
},
|
|
73
72
|
optional_obj(newValue, oldValue) {
|
|
74
|
-
Checking<
|
|
73
|
+
Checking<TestObj, typeof newValue, Test.Pass>;
|
|
75
74
|
|
|
76
|
-
Checking<
|
|
75
|
+
Checking<TestObj, typeof oldValue, Test.Pass>;
|
|
77
76
|
},
|
|
78
77
|
"optional_obj.**"(newValue, oldValue) {
|
|
79
|
-
Checking<
|
|
78
|
+
Checking<TestObj, typeof newValue, Test.Pass>;
|
|
80
79
|
|
|
81
|
-
Checking<
|
|
80
|
+
Checking<TestObj, typeof oldValue, Test.Pass>;
|
|
82
81
|
},
|
|
83
82
|
"optional_obj.subObj"(newValue, oldValue) {
|
|
84
|
-
Checking<
|
|
83
|
+
Checking<Mock_User, typeof newValue, Test.Pass>;
|
|
85
84
|
|
|
86
|
-
Checking<
|
|
85
|
+
Checking<Mock_User, typeof oldValue, Test.Pass>;
|
|
87
86
|
},
|
|
88
87
|
"required_obj.age"(newValue, oldValue) {
|
|
89
88
|
Checking<number, typeof newValue, Test.Pass>;
|
|
@@ -104,9 +103,9 @@ SubComponent<RootDoc, CompDoc>()({
|
|
|
104
103
|
Checking<string, typeof oldValue, Test.Pass>;
|
|
105
104
|
},
|
|
106
105
|
arr(newValue, oldValue) {
|
|
107
|
-
Checking<
|
|
106
|
+
Checking<string[], typeof newValue, Test.Pass>;
|
|
108
107
|
|
|
109
|
-
Checking<
|
|
108
|
+
Checking<string[], typeof oldValue, Test.Pass>;
|
|
110
109
|
},
|
|
111
110
|
|
|
112
111
|
literal_str(newValue, oldValue) {
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { DetailedType } from "../../../../..";
|
|
2
|
-
import { RootComponent } from "../../..";
|
|
3
|
-
|
|
4
|
-
interface User {
|
|
5
|
-
readonly id: number;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
slected: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
RootComponent()({
|
|
11
|
-
properties: {
|
|
12
|
-
num: Number,
|
|
13
|
-
user: Object as DetailedType<User>,
|
|
14
|
-
},
|
|
15
|
-
data: {
|
|
16
|
-
str: "123",
|
|
17
|
-
arr: [{}] as User[],
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
methods: {
|
|
21
|
-
M1() {
|
|
22
|
-
const cloneData = this.cloneData;
|
|
23
|
-
|
|
24
|
-
// @ts-expect-error 尽管cloneData去除了readonly,user.id属性依然是readonly
|
|
25
|
-
cloneData.user!.id = 1;
|
|
26
|
-
|
|
27
|
-
// @ts-expect-error arr[0].name属性依然是readonly
|
|
28
|
-
cloneData.arr[0].name = "zhao";
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import type { _ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
|
-
import type { DetailedType } from "../../../../..";
|
|
4
|
-
import { RootComponent } from "../../..";
|
|
5
|
-
|
|
6
|
-
interface User {
|
|
7
|
-
readonly id: number;
|
|
8
|
-
readonly name: string;
|
|
9
|
-
slected: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
RootComponent()({
|
|
13
|
-
properties: {
|
|
14
|
-
num: Number,
|
|
15
|
-
obj: Object as DetailedType<User>,
|
|
16
|
-
},
|
|
17
|
-
data: {
|
|
18
|
-
str: "123",
|
|
19
|
-
arr: [{}] as User[],
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
methods: {
|
|
23
|
-
M1() {
|
|
24
|
-
Checking<
|
|
25
|
-
typeof this.data,
|
|
26
|
-
_ReadonlyDeep<
|
|
27
|
-
{
|
|
28
|
-
injectTheme: "dark" | "light" | undefined;
|
|
29
|
-
injectStr: string;
|
|
30
|
-
str: string;
|
|
31
|
-
arr: User[];
|
|
32
|
-
num: number;
|
|
33
|
-
obj: User | null;
|
|
34
|
-
}
|
|
35
|
-
>,
|
|
36
|
-
Test.Pass
|
|
37
|
-
>;
|
|
38
|
-
|
|
39
|
-
Checking<
|
|
40
|
-
typeof this.cloneData,
|
|
41
|
-
{
|
|
42
|
-
injectTheme: "dark" | "light" | undefined;
|
|
43
|
-
injectStr: string;
|
|
44
|
-
str: string;
|
|
45
|
-
arr: User[];
|
|
46
|
-
num: number;
|
|
47
|
-
obj: User | null;
|
|
48
|
-
},
|
|
49
|
-
Test.Pass
|
|
50
|
-
>;
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { View } from "../../../../../thirdLib/wm";
|
|
2
|
-
import type { RootComponentDoc } from "../../../../RootComponent/RootComponentDoc";
|
|
3
|
-
import { SubComponent } from "../../..";
|
|
4
|
-
|
|
5
|
-
type RootDoc = RootComponentDoc<{
|
|
6
|
-
events: {
|
|
7
|
-
RootE1: () => string;
|
|
8
|
-
};
|
|
9
|
-
}>;
|
|
10
|
-
|
|
11
|
-
// 实例中只存在RootDoc和自身的methods字段
|
|
12
|
-
SubComponent<RootDoc, View>()({
|
|
13
|
-
lifetimes: {
|
|
14
|
-
created() {
|
|
15
|
-
// @ts-expect-error 不存在的方法 (Root事件方法不可调用)
|
|
16
|
-
this.RootE1;
|
|
17
|
-
|
|
18
|
-
// @ts-expect-error 不存在的方法
|
|
19
|
-
this.otherMethods();
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import type { ComponentDoc } from "../../../../DefineComponent/ReturnType/ComponentDoc";
|
|
3
|
-
import type { Mock_User } from "../../../../RootComponent/Properties/test/normalRequired.test";
|
|
4
|
-
import type { RootComponentDoc } from "../../../../RootComponent/RootComponentDoc";
|
|
5
|
-
import { SubComponent } from "../../..";
|
|
6
|
-
|
|
7
|
-
type RootDoc = RootComponentDoc<{
|
|
8
|
-
properties: {
|
|
9
|
-
Pstr: string;
|
|
10
|
-
Pobj: Mock_User | null;
|
|
11
|
-
PoptionalObj?: Mock_User;
|
|
12
|
-
};
|
|
13
|
-
data: {
|
|
14
|
-
Dnum: number;
|
|
15
|
-
};
|
|
16
|
-
computed: {
|
|
17
|
-
Cnum: number;
|
|
18
|
-
};
|
|
19
|
-
methods: {
|
|
20
|
-
RootM: () => number;
|
|
21
|
-
};
|
|
22
|
-
customEvents: {
|
|
23
|
-
RootCus: string;
|
|
24
|
-
};
|
|
25
|
-
events: {
|
|
26
|
-
RootE1: () => string;
|
|
27
|
-
};
|
|
28
|
-
}>;
|
|
29
|
-
|
|
30
|
-
type CompDoc = ComponentDoc<{
|
|
31
|
-
properties: {
|
|
32
|
-
aaa_str: string;
|
|
33
|
-
};
|
|
34
|
-
customEvents: {
|
|
35
|
-
aaa_num: number;
|
|
36
|
-
};
|
|
37
|
-
}>;
|
|
38
|
-
|
|
39
|
-
SubComponent<RootDoc, CompDoc>()({
|
|
40
|
-
data: {
|
|
41
|
-
aaa_str: "str",
|
|
42
|
-
_aaa_num: 123,
|
|
43
|
-
},
|
|
44
|
-
computed: {
|
|
45
|
-
_aaa_isReady() {
|
|
46
|
-
return false;
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
lifetimes: {
|
|
51
|
-
created() {
|
|
52
|
-
Checking<
|
|
53
|
-
typeof this.cloneData,
|
|
54
|
-
{
|
|
55
|
-
// inheritData
|
|
56
|
-
injectTheme: "dark" | "light" | undefined;
|
|
57
|
-
injectStr: string;
|
|
58
|
-
// RootData
|
|
59
|
-
Pstr: string;
|
|
60
|
-
Pobj: Mock_User | null;
|
|
61
|
-
PoptionalObj: Mock_User;
|
|
62
|
-
Dnum: number;
|
|
63
|
-
Cnum: number;
|
|
64
|
-
// 自身Data类型与CompDoc类型相同
|
|
65
|
-
aaa_str: string;
|
|
66
|
-
_aaa_isReady: boolean;
|
|
67
|
-
_aaa_num: number;
|
|
68
|
-
},
|
|
69
|
-
Test.Pass
|
|
70
|
-
>;
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
});
|