annil 1.1.1 → 1.2.0-beta.0
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 +14 -0
- package/dist/api/DefineComponent/collectOptionsForComponent.d.ts +2 -2
- package/dist/api/DefineComponent/collectOptionsForComponent.js +24 -28
- package/dist/api/DefineComponent/collectOptionsForComponent.js.map +1 -1
- package/dist/api/DefineComponent/index.d.ts +12 -12
- package/dist/api/DefineComponent/index.js.map +1 -1
- package/dist/api/RootComponent/Computed/ComputedOption.d.ts +2 -2
- package/dist/api/RootComponent/Computed/GetComputedDoc.d.ts +2 -2
- package/dist/api/RootComponent/Computed/test/normal.test.js +5 -12
- package/dist/api/RootComponent/Computed/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/CustomEvents/CustomEventsOption.d.ts +2 -2
- package/dist/api/RootComponent/Data/DataConstraint.d.ts +1 -1
- package/dist/api/RootComponent/Data/DataOption.d.ts +2 -2
- package/dist/api/RootComponent/Data/GetDataDoc.d.ts +1 -4
- package/dist/api/RootComponent/Data/test/GetDataDoc.test.d.ts +3 -2
- package/dist/api/RootComponent/Data/test/GetDataDoc.test.js +5 -5
- package/dist/api/RootComponent/Data/test/GetDataDoc.test.js.map +1 -1
- package/dist/api/RootComponent/Data/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Events/EventsConstraint.d.ts +6 -5
- package/dist/api/RootComponent/Events/EventsOption.d.ts +2 -3
- package/dist/api/RootComponent/Events/test/normal.test.js +1 -1
- package/dist/api/RootComponent/Events/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Lifetimes/LifetimesConstraint.d.ts +5 -4
- package/dist/api/RootComponent/Lifetimes/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/PageLifetimes/PageLifetimesOption.d.ts +6 -7
- package/dist/api/RootComponent/PageLifetimes/test/error.test.js +3 -1
- package/dist/api/RootComponent/PageLifetimes/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/PageLifetimes/test/normal.test.js +3 -1
- package/dist/api/RootComponent/PageLifetimes/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/RootComponentDoc.d.ts +17 -3
- package/dist/api/RootComponent/Store/GeTStoreDoc.d.ts +1 -1
- package/dist/api/RootComponent/Store/StoreOption.d.ts +2 -2
- package/dist/api/RootComponent/Store/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Watch/test/WatchProperties.test.js +0 -2
- package/dist/api/RootComponent/Watch/test/WatchProperties.test.js.map +1 -1
- package/dist/api/RootComponent/index.d.ts +9 -10
- package/dist/api/RootComponent/index.js.map +1 -1
- package/dist/api/SubComponent/SubData/SubDataConstraint.d.ts +2 -2
- package/dist/api/SubComponent/SubData/test/normal.test.js +0 -15
- package/dist/api/SubComponent/SubData/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/SubEvents/SubEventsConstraint.d.ts +2 -2
- package/dist/api/SubComponent/SubEvents/SubEventsOptions.d.ts +2 -2
- package/dist/api/SubComponent/SubEvents/test/error.test.js.map +1 -1
- package/dist/api/SubComponent/SubEvents/test/normal.test.js +20 -0
- package/dist/api/SubComponent/SubEvents/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/SubInherit/SubInheritConstraint.d.ts +3 -2
- package/dist/api/SubComponent/SubInherit/SubInheritOption.d.ts +3 -0
- package/dist/api/SubComponent/SubInherit/SubInheritOption.js +2 -0
- package/dist/api/SubComponent/SubInherit/SubInheritOption.js.map +1 -0
- package/dist/api/SubComponent/SubInherit/test/error.test.js +1 -1
- package/dist/api/SubComponent/SubInherit/test/error.test.js.map +1 -1
- package/dist/api/SubComponent/SubInherit/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/SubMethods/SubMethodsOption.d.ts +3 -2
- package/dist/api/SubComponent/SubMethods/test/error.test.js +6 -0
- package/dist/api/SubComponent/SubMethods/test/error.test.js.map +1 -1
- package/dist/api/SubComponent/SubMethods/test/normarl.test.js +3 -3
- package/dist/api/SubComponent/SubMethods/test/normarl.test.js.map +1 -1
- package/dist/api/SubComponent/SubPageLifetimes/SubPageLifetimesOption.d.ts +1 -1
- package/dist/api/SubComponent/SubPageLifetimes/test/error.test.d.ts +0 -1
- package/dist/api/SubComponent/SubPageLifetimes/test/error.test.js +1 -11
- package/dist/api/SubComponent/SubPageLifetimes/test/error.test.js.map +1 -1
- package/dist/api/SubComponent/SubPageLifetimes/test/normal.test.d.ts +0 -1
- package/dist/api/SubComponent/SubPageLifetimes/test/normal.test.js +1 -25
- package/dist/api/SubComponent/SubPageLifetimes/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/SubStore/SubDataConstraint.d.ts +2 -2
- package/dist/api/SubComponent/SubStore/SubStoreOption.d.ts +1 -1
- package/dist/api/SubComponent/SubStore/test/error.test.js +2 -0
- package/dist/api/SubComponent/SubStore/test/error.test.js.map +1 -1
- package/dist/api/SubComponent/SubStore/test/normal.test.js +1 -0
- package/dist/api/SubComponent/SubStore/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/SubWatch/SubWatchOption.d.ts +2 -1
- package/dist/api/SubComponent/SubWatch/test/WatchComputed.test.d.ts +1 -0
- package/dist/api/SubComponent/SubWatch/test/WatchComputed.test.js +44 -1
- package/dist/api/SubComponent/SubWatch/test/WatchComputed.test.js.map +1 -1
- package/dist/api/SubComponent/SubWatch/test/error.test.js +10 -2
- package/dist/api/SubComponent/SubWatch/test/error.test.js.map +1 -1
- package/dist/api/SubComponent/index.d.ts +19 -13
- package/dist/api/SubComponent/index.js.map +1 -1
- package/dist/behaviors/BComputedAndWatch/index.js.map +1 -1
- package/dist/behaviors/BComputedAndWatch/types.d.ts +1 -0
- package/dist/behaviors/BStore.js.map +1 -1
- package/dist/behaviors/BbeforeCreated.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/OfficialTypeAlias.d.ts +1 -1
- package/dist/types/RemoveInnerData.d.ts +1 -0
- package/dist/types/RemoveInnerData.js +2 -0
- package/dist/types/RemoveInnerData.js.map +1 -0
- package/dist/utils/InnerMarker.js +1 -1
- package/dist/utils/InnerMarker.js.map +1 -1
- package/dist/utils/deepClone.js.map +1 -1
- package/package.json +4 -2
- package/src/api/DefineComponent/collectOptionsForComponent.ts +176 -66
- package/src/api/DefineComponent/index.ts +13 -9
- package/src/api/RootComponent/Computed/ComputedOption.ts +23 -3
- package/src/api/RootComponent/Computed/GetComputedDoc.ts +1 -3
- package/src/api/RootComponent/Computed/test/normal.test.ts +9 -19
- package/src/api/RootComponent/CustomEvents/CustomEventsOption.ts +26 -22
- package/src/api/RootComponent/CustomEvents/test/error.test.ts +5 -5
- package/src/api/RootComponent/CustomEvents/test/normal.test.ts +1 -1
- package/src/api/RootComponent/Data/DataConstraint.ts +1 -1
- package/src/api/RootComponent/Data/DataOption.ts +6 -4
- package/src/api/RootComponent/Data/GetDataDoc.ts +1 -18
- package/src/api/RootComponent/Data/test/GetDataDoc.test.ts +14 -25
- package/src/api/RootComponent/Data/test/error.test.ts +2 -2
- package/src/api/RootComponent/Data/test/normal.test.ts +5 -8
- package/src/api/RootComponent/Events/EventsConstraint.ts +24 -19
- package/src/api/RootComponent/Events/EventsOption.ts +54 -6
- package/src/api/RootComponent/Events/test/normal.test.ts +16 -16
- package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +1 -1
- package/src/api/RootComponent/IsPage/IsPageOption.ts +1 -1
- package/src/api/RootComponent/Lifetimes/LifetimesConstraint.ts +11 -8
- package/src/api/RootComponent/Lifetimes/LifetimesOption.ts +26 -0
- package/src/api/RootComponent/Lifetimes/test/error.test.ts +3 -13
- package/src/api/RootComponent/Lifetimes/test/normal.test.ts +1 -1
- package/src/api/RootComponent/Methods/MethodsOption.ts +3 -0
- package/src/api/RootComponent/PageLifetimes/PageLifetimesOption.ts +21 -10
- package/src/api/RootComponent/PageLifetimes/test/error.test.ts +7 -5
- package/src/api/RootComponent/PageLifetimes/test/normal.test.ts +9 -10
- package/src/api/RootComponent/Properties/PropertiesOption.ts +19 -32
- package/src/api/RootComponent/RootComponentDoc.ts +19 -3
- package/src/api/RootComponent/Store/GeTStoreDoc.ts +1 -1
- package/src/api/RootComponent/Store/StoreOption.ts +14 -2
- package/src/api/RootComponent/Store/test/error.test.ts +5 -5
- package/src/api/RootComponent/Store/test/normal.test.ts +1 -0
- package/src/api/RootComponent/Watch/test/WatchProperties.test.ts +1 -12
- package/src/api/RootComponent/index.ts +20 -19
- package/src/api/SubComponent/SubComputed/SubComputedOption.ts +0 -1
- package/src/api/SubComponent/SubData/SubDataConstraint.ts +2 -3
- package/src/api/SubComponent/SubData/SubDataOption.ts +4 -0
- package/src/api/SubComponent/SubData/test/error.test.ts +1 -1
- package/src/api/SubComponent/SubData/test/normal.test.ts +6 -37
- package/src/api/SubComponent/SubEvents/SubEventsConstraint.ts +7 -2
- package/src/api/SubComponent/SubEvents/SubEventsOptions.ts +7 -2
- package/src/api/SubComponent/SubEvents/test/error.test.ts +5 -4
- package/src/api/SubComponent/SubEvents/test/normal.test.ts +31 -4
- package/src/api/SubComponent/SubInherit/SubInheritConstraint.ts +6 -3
- package/src/api/SubComponent/SubInherit/SubInheritOption.ts +8 -0
- package/src/api/SubComponent/SubInherit/test/error.test.ts +9 -7
- package/src/api/SubComponent/SubInherit/test/normal.test.ts +5 -4
- package/src/api/SubComponent/SubMethods/SubMethodsOption.ts +7 -3
- package/src/api/SubComponent/SubMethods/test/error.test.ts +13 -5
- package/src/api/SubComponent/SubMethods/test/normarl.test.ts +6 -12
- package/src/api/SubComponent/SubPageLifetimes/SubPageLifetimesOption.ts +2 -2
- package/src/api/SubComponent/SubPageLifetimes/test/error.test.ts +1 -32
- package/src/api/SubComponent/SubPageLifetimes/test/normal.test.ts +1 -74
- package/src/api/SubComponent/SubStore/SubDataConstraint.ts +2 -2
- package/src/api/SubComponent/SubStore/SubStoreOption.ts +15 -1
- package/src/api/SubComponent/SubStore/test/error.test.ts +4 -0
- package/src/api/SubComponent/SubStore/test/normal.test.ts +2 -0
- package/src/api/SubComponent/SubWatch/SubWatchOption.ts +2 -1
- package/src/api/SubComponent/SubWatch/test/WatchComputed.test.ts +75 -43
- package/src/api/SubComponent/SubWatch/test/error.test.ts +12 -3
- package/src/api/SubComponent/index.ts +28 -17
- package/src/behaviors/BComputedAndWatch/index.ts +2 -2
- package/src/behaviors/BComputedAndWatch/types.ts +1 -0
- package/src/behaviors/BStore.ts +4 -6
- package/src/behaviors/BbeforeCreated.ts +2 -2
- package/src/index.ts +12 -8
- package/src/types/OfficialTypeAlias.ts +7 -11
- package/src/types/RemoveInnerData.ts +5 -0
- package/src/utils/InnerMarker.ts +1 -1
- package/src/utils/deepClone.ts +1 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
2
|
import type { Wm } from "../../../../thirdLib";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import type { Detail, Mark, WMBaseEvent } from "../../../..";
|
|
4
5
|
import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc";
|
|
5
6
|
import type {
|
|
6
7
|
Bubbles,
|
|
@@ -10,6 +11,7 @@ import type {
|
|
|
10
11
|
Capture,
|
|
11
12
|
CaptureComposed,
|
|
12
13
|
} from "../../../RootComponent/CustomEvents/CustomEventsTag";
|
|
14
|
+
import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
|
|
13
15
|
import { SubComponent } from "../..";
|
|
14
16
|
|
|
15
17
|
type CompDoc = ComponentDoc<{
|
|
@@ -51,13 +53,13 @@ const sub1 = SubComponent<{}, CompDoc>()({
|
|
|
51
53
|
},
|
|
52
54
|
});
|
|
53
55
|
|
|
54
|
-
// 1.2 Composed事件会被返回
|
|
55
56
|
type Sub1Expected = {
|
|
56
57
|
BubblesComposed: string | BubblesComposed;
|
|
57
58
|
CapturePhaseComposed: string | CaptureComposed;
|
|
58
59
|
BubblesCapturePhaseComposed: string | BubblesCaptureComposed;
|
|
59
60
|
};
|
|
60
61
|
|
|
62
|
+
// 1.2 Composed事件会被返回
|
|
61
63
|
Checking<typeof sub1, Sub1Expected, Test.Pass>;
|
|
62
64
|
|
|
63
65
|
// 2.1 key可写入后缀字段(_catch,表示阻止冒泡和捕获事件)。
|
|
@@ -75,7 +77,6 @@ const sub2 = SubComponent<{}, CompDoc>()({
|
|
|
75
77
|
// 2.2 返回没有被加后最(_catch)的Composed事件
|
|
76
78
|
Checking<typeof sub2, { BubblesCapturePhaseComposed: string | BubblesCaptureComposed }, Test.Pass>;
|
|
77
79
|
|
|
78
|
-
// 2.3 key可写入后缀字段(_catch,表示阻止冒泡和捕获事件)。
|
|
79
80
|
const sub3 = SubComponent<{}, CompDoc>()({
|
|
80
81
|
events: {
|
|
81
82
|
aaa_BubblesComposed_catch(e) {
|
|
@@ -106,7 +107,7 @@ SubComponent<{}, Wm.View>()({
|
|
|
106
107
|
},
|
|
107
108
|
});
|
|
108
109
|
|
|
109
|
-
// 3.
|
|
110
|
+
// 3.1 基础组件自定义事件参数为Detail<object>
|
|
110
111
|
SubComponent<{}, Wm.ScrollView>()({
|
|
111
112
|
events: {
|
|
112
113
|
scrollView_bindscroll(e) {
|
|
@@ -126,3 +127,29 @@ SubComponent<{}, Wm.ScrollView>()({
|
|
|
126
127
|
// ...
|
|
127
128
|
},
|
|
128
129
|
});
|
|
130
|
+
|
|
131
|
+
// 4 可为事件自定义类型
|
|
132
|
+
SubComponent<{}, Wm.View>()({
|
|
133
|
+
events: {
|
|
134
|
+
view_tap(e: Detail<number>) {
|
|
135
|
+
Checking<typeof e.detail, number, Test.Pass>;
|
|
136
|
+
},
|
|
137
|
+
view_longtap(e: Mark<Mock_User>) {
|
|
138
|
+
Checking<typeof e.mark, Mock_User, Test.Pass>;
|
|
139
|
+
},
|
|
140
|
+
// ...
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// 4 可为事件自定义类型
|
|
145
|
+
SubComponent<{}, Wm.View>()({
|
|
146
|
+
events: {
|
|
147
|
+
view_tap(e: Detail<number>) {
|
|
148
|
+
Checking<typeof e.detail, number, Test.Pass>;
|
|
149
|
+
},
|
|
150
|
+
view_longtap(e: Mark<Mock_User>) {
|
|
151
|
+
Checking<typeof e.mark, Mock_User, Test.Pass>;
|
|
152
|
+
},
|
|
153
|
+
// ...
|
|
154
|
+
},
|
|
155
|
+
});
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { SelectKeys } from "hry-types/src/Object/_api";
|
|
2
|
+
import type { RemoveInnerData } from "../../../types/RemoveInnerData";
|
|
2
3
|
import type { ComponentDoc } from "../../DefineComponent/ReturnType/ComponentDoc";
|
|
3
4
|
|
|
4
5
|
type WXMLSign = "wxml";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
* 子组件inherit字段约束,
|
|
8
|
+
* 子组件inherit字段约束,key为子组件所需key,根组件数据的key或`WXMLSign`。要求根数据类型为子数据类型的子类型。当key的值来自wxml(循环产生的子数据等情况)时用`WXMLSign`表示。
|
|
8
9
|
* @returns object
|
|
9
10
|
*/
|
|
10
|
-
export type InheritConstraint<
|
|
11
|
-
[k in keyof TComponentDoc["properties"]]?:
|
|
11
|
+
export type InheritConstraint<AllRootData extends object, TComponentDoc extends ComponentDoc> = {
|
|
12
|
+
[k in keyof TComponentDoc["properties"]]?:
|
|
13
|
+
| RemoveInnerData<SelectKeys<AllRootData, TComponentDoc["properties"][k]> & string>
|
|
14
|
+
| WXMLSign;
|
|
12
15
|
};
|
|
@@ -17,6 +17,8 @@ type Mock_RootDoc = RootComponentDoc<{
|
|
|
17
17
|
str: string;
|
|
18
18
|
literal_str: "a" | "b" | "c";
|
|
19
19
|
bool: boolean;
|
|
20
|
+
_num: number;
|
|
21
|
+
_str: string;
|
|
20
22
|
};
|
|
21
23
|
computed: {
|
|
22
24
|
Cuinon: string | boolean;
|
|
@@ -34,19 +36,19 @@ type Mock_CompDoc = ComponentDoc<{
|
|
|
34
36
|
};
|
|
35
37
|
}>;
|
|
36
38
|
|
|
37
|
-
//
|
|
39
|
+
// 1 继承字段类型错误
|
|
38
40
|
SubComponent<Mock_RootDoc, Mock_CompDoc>()({
|
|
39
41
|
inherit: {
|
|
40
|
-
// @ts-expect-error
|
|
42
|
+
// @ts-expect-error 1.1 [string | number] 不是 [number] 的子集
|
|
41
43
|
aaa_num: "unionStrNum",
|
|
42
|
-
// @ts-expect-error
|
|
44
|
+
// @ts-expect-error 1.2 [123 | 456 | 789] 不是 [123 | 456] 的子集
|
|
43
45
|
aaa_literal_num: "optional_literal_num",
|
|
44
|
-
// @ts-expect-error
|
|
45
|
-
aaa_str: ""
|
|
46
|
+
// @ts-expect-error 1.3 不可继承内部字段
|
|
47
|
+
aaa_str: "_str",
|
|
46
48
|
},
|
|
47
49
|
});
|
|
48
50
|
|
|
49
|
-
// inherit
|
|
51
|
+
// 2 inherit字段最终不会在组件配置中,意义在于通过声明继承字段便于类型判断,配置是否满足子组件文档的需求。下面示例中,配置不满足组件需求,Mock_CompDoc需要一些必传字段没有配置,即使这些字段存在在于根组件(或wmxl).而返回的字符串(错误),无法通过DefinedComponent Api 类型检测。
|
|
50
52
|
const subDoc = SubComponent<Mock_RootDoc, Mock_CompDoc>()({
|
|
51
53
|
data: {
|
|
52
54
|
aaa_num: 123,
|
|
@@ -57,6 +59,6 @@ Checking<typeof subDoc, SubComponentDoc, Test.Fail>;
|
|
|
57
59
|
|
|
58
60
|
DefineComponent({
|
|
59
61
|
name: "xxx",
|
|
60
|
-
// @ts-expect-error 不能将类型“string”分配给类型“_SubComponentDoc”。
|
|
62
|
+
// @ts-expect-error 2 不能将类型“string”分配给类型“_SubComponentDoc”。
|
|
61
63
|
subComponents: [subDoc],
|
|
62
64
|
});
|
|
@@ -2,13 +2,16 @@ import type { ComponentDoc } from "../../../DefineComponent/ReturnType/Component
|
|
|
2
2
|
import type { RootComponentDoc } from "../../../RootComponent/RootComponentDoc";
|
|
3
3
|
import { SubComponent } from "../..";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* inherit字段最终会在选项中删除,它用ts开发类型检测。
|
|
7
|
+
*/
|
|
5
8
|
type Mock_RootDoc = RootComponentDoc<{
|
|
6
9
|
properties: {
|
|
7
10
|
required_num: number;
|
|
8
11
|
optional_literal_num?: 123 | 456 | 789;
|
|
9
12
|
unionStrNum: string | number;
|
|
10
13
|
required_obj: object | null;
|
|
11
|
-
optional_obj?: object;
|
|
14
|
+
optional_obj?: object | null;
|
|
12
15
|
};
|
|
13
16
|
data: {
|
|
14
17
|
str: string;
|
|
@@ -31,7 +34,7 @@ type Mock_CompDoc = ComponentDoc<{
|
|
|
31
34
|
};
|
|
32
35
|
}>;
|
|
33
36
|
|
|
34
|
-
// 1 没有可继承的数据,类型可为'wxml',表示数据来自wxml(
|
|
37
|
+
// 1 没有可继承的数据,类型可为'wxml',表示数据来自wxml(例如数据来自父元素循环wx:for后的数据等情况)
|
|
35
38
|
SubComponent<{}, Mock_CompDoc>()({
|
|
36
39
|
inherit: {
|
|
37
40
|
aaa_num: "wxml",
|
|
@@ -51,5 +54,3 @@ SubComponent<Mock_RootDoc, Mock_CompDoc>()({
|
|
|
51
54
|
aaa_obj1: "" as "required_obj" | "optional_obj" | "wxml",
|
|
52
55
|
},
|
|
53
56
|
});
|
|
54
|
-
|
|
55
|
-
// inherit字段最终会在配置对象中删除,它用类型检测。
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { V } from "hry-types";
|
|
2
2
|
import type { PrefixValidator } from "hry-types/src/Generic/PrefixValidator";
|
|
3
|
+
import type { SubMethodsConstraint } from "./SubMethodsConstraint";
|
|
3
4
|
|
|
4
5
|
export type SubMethodsOption<
|
|
5
|
-
TSubMethods extends
|
|
6
|
+
TSubMethods extends SubMethodsConstraint,
|
|
6
7
|
TPrefix extends string,
|
|
7
|
-
|
|
8
|
+
ExcludedKeys extends PropertyKey,
|
|
8
9
|
> = {
|
|
10
|
+
/**
|
|
11
|
+
* 前缀检测和重复检测(与events和组件customEvents字段)
|
|
12
|
+
*/
|
|
9
13
|
methods?:
|
|
10
14
|
& TSubMethods
|
|
11
15
|
& PrefixValidator<TSubMethods, TPrefix>
|
|
12
|
-
& V.DuplicateFieldValidator<TSubMethods,
|
|
16
|
+
& V.DuplicateFieldValidator<TSubMethods, ExcludedKeys>;
|
|
13
17
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc";
|
|
2
|
+
import type { Bubbles } from "../../../RootComponent/CustomEvents/CustomEventsTag";
|
|
2
3
|
import type { RootComponentDoc } from "../../../RootComponent/RootComponentDoc";
|
|
3
4
|
import { SubComponent } from "../..";
|
|
4
5
|
|
|
@@ -16,22 +17,29 @@ type RootDoc = RootComponentDoc<{
|
|
|
16
17
|
|
|
17
18
|
type CompDoc = ComponentDoc<{
|
|
18
19
|
customEvents: {
|
|
19
|
-
aaa_str: string;
|
|
20
|
+
aaa_str: string | Bubbles;
|
|
20
21
|
};
|
|
21
22
|
}>;
|
|
22
23
|
|
|
23
|
-
// 前缀错误
|
|
24
|
+
// 1 前缀错误
|
|
24
25
|
SubComponent<RootDoc, CompDoc>()({
|
|
25
26
|
methods: {
|
|
26
|
-
// @ts-expect-error 前缀错误
|
|
27
|
+
// @ts-expect-error 1.1 前缀错误
|
|
27
28
|
xxx_yyy() {},
|
|
28
29
|
},
|
|
29
30
|
});
|
|
30
31
|
|
|
31
|
-
//
|
|
32
|
+
// 2 重复检测
|
|
32
33
|
SubComponent<RootDoc, CompDoc>()({
|
|
34
|
+
events: {
|
|
35
|
+
aaa_str_catch() {
|
|
36
|
+
},
|
|
37
|
+
},
|
|
33
38
|
methods: {
|
|
34
|
-
// @ts-expect-error
|
|
39
|
+
// @ts-expect-error 2.1 与组件自定义事件字段重复
|
|
35
40
|
aaa_str() {},
|
|
41
|
+
// @ts-expect-error 2.2 与events字段重复
|
|
42
|
+
aaa_str_catch() {
|
|
43
|
+
},
|
|
36
44
|
},
|
|
37
45
|
});
|
|
@@ -6,12 +6,6 @@ type RootDoc = RootComponentDoc<{
|
|
|
6
6
|
methods: {
|
|
7
7
|
Mstr: () => string;
|
|
8
8
|
};
|
|
9
|
-
events: {
|
|
10
|
-
Estr: () => string;
|
|
11
|
-
};
|
|
12
|
-
customEvents: {
|
|
13
|
-
Cstr: string;
|
|
14
|
-
};
|
|
15
9
|
}>;
|
|
16
10
|
|
|
17
11
|
type CompDoc = ComponentDoc<{
|
|
@@ -20,12 +14,7 @@ type CompDoc = ComponentDoc<{
|
|
|
20
14
|
};
|
|
21
15
|
}>;
|
|
22
16
|
|
|
23
|
-
//
|
|
24
|
-
SubComponent<RootDoc, CompDoc>()({
|
|
25
|
-
methods: {},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// methods字段可以写 任意字段函数,不与RootDoc和CompDoc中的方法字段重复即可,前缀为CompDoc的前缀
|
|
17
|
+
// methods字段同组件前缀
|
|
29
18
|
SubComponent<RootDoc, CompDoc>()({
|
|
30
19
|
methods: {
|
|
31
20
|
aaa_xxx() {},
|
|
@@ -33,3 +22,8 @@ SubComponent<RootDoc, CompDoc>()({
|
|
|
33
22
|
// ...
|
|
34
23
|
},
|
|
35
24
|
});
|
|
25
|
+
|
|
26
|
+
// 2 默认可以为{}。
|
|
27
|
+
SubComponent<RootDoc, CompDoc>()({
|
|
28
|
+
methods: {},
|
|
29
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PageLifetimesOption } from "../../RootComponent/PageLifetimes/PageLifetimesOption";
|
|
2
2
|
|
|
3
|
-
export type SubPageLifetimesOption<TIsPage extends boolean,
|
|
3
|
+
export type SubPageLifetimesOption<TIsPage extends boolean, PropertiesDoc extends object> = PageLifetimesOption<
|
|
4
4
|
TIsPage,
|
|
5
|
-
|
|
5
|
+
PropertiesDoc
|
|
6
6
|
>;
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { SubComponent } from "../..";
|
|
3
|
-
|
|
4
|
-
type RootDocCompPage = RootComponentDoc<{
|
|
5
|
-
isPage: true;
|
|
6
|
-
}>;
|
|
7
|
-
|
|
8
|
-
type CompDoc = RootComponentDoc<{
|
|
9
|
-
properties: {
|
|
10
|
-
aaa_str: string;
|
|
11
|
-
};
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 测试 组件时
|
|
16
|
-
*/
|
|
17
|
-
SubComponent<{}, CompDoc>()({
|
|
18
|
-
pageLifetimes: {
|
|
19
|
-
// @ts-expect-error 不存在的字段 show是正确字段
|
|
20
|
-
onShow() {},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 页面时
|
|
26
|
-
*/
|
|
27
|
-
SubComponent<RootDocCompPage, CompDoc>()({
|
|
28
|
-
pageLifetimes: {
|
|
29
|
-
// @ts-expect-error 不存在的字段 多了一个 `d`
|
|
30
|
-
onLoadd() {},
|
|
31
|
-
},
|
|
32
|
-
});
|
|
1
|
+
// 同 RootComponent的PageLifetimes
|
|
@@ -1,74 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 RootDocComp = RootComponentDoc<{
|
|
8
|
-
properties: {
|
|
9
|
-
union?: Mock_User;
|
|
10
|
-
optionalObject?: Mock_User | null;
|
|
11
|
-
str: string;
|
|
12
|
-
obj: object | null;
|
|
13
|
-
};
|
|
14
|
-
}>;
|
|
15
|
-
|
|
16
|
-
type RootDocCompPage = RootComponentDoc<{
|
|
17
|
-
isPage: true;
|
|
18
|
-
properties: {
|
|
19
|
-
union?: Mock_User;
|
|
20
|
-
optionalObject?: Mock_User | null;
|
|
21
|
-
str: string;
|
|
22
|
-
obj: object | null;
|
|
23
|
-
};
|
|
24
|
-
}>;
|
|
25
|
-
|
|
26
|
-
type CompDoc = RootComponentDoc<{
|
|
27
|
-
properties: {
|
|
28
|
-
aaa_str: string;
|
|
29
|
-
};
|
|
30
|
-
customEvents: {
|
|
31
|
-
aaa_num: number;
|
|
32
|
-
};
|
|
33
|
-
}>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 测试 组件时
|
|
37
|
-
*/
|
|
38
|
-
SubComponent<RootDocComp, CompDoc>()({
|
|
39
|
-
pageLifetimes: {
|
|
40
|
-
hide() {},
|
|
41
|
-
load() {},
|
|
42
|
-
resize(size) {
|
|
43
|
-
Checking<typeof size, WechatMiniprogram.Page.IResizeOption, Test.Pass>;
|
|
44
|
-
},
|
|
45
|
-
show() {},
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 页面时
|
|
51
|
-
*/
|
|
52
|
-
SubComponent<RootDocCompPage, CompDoc>()({
|
|
53
|
-
pageLifetimes: {
|
|
54
|
-
onLoad(props) {
|
|
55
|
-
// 接受的必传properties字段,不应该有null
|
|
56
|
-
Checking<
|
|
57
|
-
typeof props,
|
|
58
|
-
{
|
|
59
|
-
str: string;
|
|
60
|
-
obj: object;
|
|
61
|
-
union: Mock_User;
|
|
62
|
-
optionalObject: Mock_User | null;
|
|
63
|
-
},
|
|
64
|
-
Test.Pass
|
|
65
|
-
>;
|
|
66
|
-
},
|
|
67
|
-
onHide() {
|
|
68
|
-
console.log("onHide");
|
|
69
|
-
},
|
|
70
|
-
onResize(options) {
|
|
71
|
-
console.log("onResize", options);
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
});
|
|
1
|
+
// 同 RootComponent的PageLifetimes
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import type { V } from "hry-types";
|
|
2
2
|
|
|
3
3
|
export type SubStoreOption<TSubStore extends object, legalKeys extends PropertyKey, TPrefix extends string> = {
|
|
4
|
+
/**
|
|
5
|
+
* 全局响应式数据字段,全局store对应数据变化实例对应数据自动setData。
|
|
6
|
+
* 约束为组件properties字段去除inherit和data的剩余字段和内部字段
|
|
7
|
+
* 有非法字段(除了约束字段外的字段)检测
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* {
|
|
11
|
+
* //...
|
|
12
|
+
* store: {
|
|
13
|
+
* aaa_str: () => sroreX.str,
|
|
14
|
+
* },
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
4
18
|
store?:
|
|
5
19
|
& TSubStore
|
|
6
20
|
& V.IllegalFieldValidator<
|
|
@@ -8,6 +22,6 @@ export type SubStoreOption<TSubStore extends object, legalKeys extends PropertyK
|
|
|
8
22
|
legalKeys | `_${TPrefix}_${string}`,
|
|
9
23
|
0,
|
|
10
24
|
"",
|
|
11
|
-
"
|
|
25
|
+
"与inherit和data字段重复或前缀错误"
|
|
12
26
|
>;
|
|
13
27
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NoInfer } from "hry-types/src/Generic/NoInfer";
|
|
1
2
|
import type { WatchOption } from "../../RootComponent/Watch/WatchOption";
|
|
2
3
|
|
|
3
|
-
export type SubWatchOption<TWatchData extends object> = WatchOption<TWatchData
|
|
4
|
+
export type SubWatchOption<TWatchData extends object> = WatchOption<NoInfer<TWatchData>>;
|
|
@@ -1,46 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
obj: Mock_User | null;
|
|
10
|
+
};
|
|
11
|
+
data: {
|
|
12
|
+
num: number;
|
|
13
|
+
};
|
|
14
|
+
store: {
|
|
15
|
+
bool: boolean;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
type CompDoc = ComponentDoc<{
|
|
20
|
+
properties: {
|
|
21
|
+
aaa_obj: Mock_User | null;
|
|
22
|
+
aaa_str: string;
|
|
23
|
+
aaa_num: number;
|
|
24
|
+
aaa_bool: boolean;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
18
27
|
|
|
19
28
|
/**
|
|
20
|
-
*
|
|
29
|
+
* watch computed字段时需要手写类型,可悬停鼠标到key查看类型
|
|
21
30
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
SubComponent<RootDoc, CompDoc>()({
|
|
32
|
+
computed: {
|
|
33
|
+
aaa_str(): string {
|
|
34
|
+
return this.data.aaa_num.toString();
|
|
35
|
+
},
|
|
36
|
+
aaa_num(): number {
|
|
37
|
+
return 123;
|
|
38
|
+
},
|
|
39
|
+
aaa_bool(): boolean {
|
|
40
|
+
return this.data.bool;
|
|
41
|
+
},
|
|
42
|
+
aaa_obj(): Mock_User {
|
|
43
|
+
return {} as Mock_User;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
watch: {
|
|
47
|
+
aaa_num(newValue: number, oldValue: number) {
|
|
48
|
+
Checking<number, typeof newValue, Test.Pass>;
|
|
49
|
+
|
|
50
|
+
Checking<number, typeof oldValue, Test.Pass>;
|
|
51
|
+
},
|
|
52
|
+
aaa_str(newValue: string, oldValue: string) {
|
|
53
|
+
Checking<string, typeof newValue, Test.Pass>;
|
|
54
|
+
|
|
55
|
+
Checking<string, typeof oldValue, Test.Pass>;
|
|
56
|
+
},
|
|
57
|
+
aaa_bool(newValue: boolean, oldValue: boolean) {
|
|
58
|
+
Checking<boolean, typeof newValue, Test.Pass>;
|
|
59
|
+
|
|
60
|
+
Checking<boolean, typeof oldValue, Test.Pass>;
|
|
61
|
+
},
|
|
62
|
+
aaa_obj(newValue: Mock_User, oldValue: Mock_User | null) {
|
|
63
|
+
Checking<Mock_User, typeof newValue, Test.Pass>;
|
|
64
|
+
|
|
65
|
+
Checking<Mock_User | null, typeof oldValue, Test.Pass>;
|
|
66
|
+
},
|
|
67
|
+
"aaa_obj.id"(newValue: string, oldValue: string) {
|
|
68
|
+
Checking<string, typeof newValue, Test.Pass>;
|
|
69
|
+
|
|
70
|
+
Checking<string, typeof oldValue, Test.Pass>;
|
|
71
|
+
},
|
|
72
|
+
"aaa_obj.age"(newValue: number, oldValue: number) {
|
|
73
|
+
Checking<number, typeof newValue, Test.Pass>;
|
|
74
|
+
|
|
75
|
+
Checking<number, typeof oldValue, Test.Pass>;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
});
|
|
@@ -5,7 +5,7 @@ import { SubComponent } from "../..";
|
|
|
5
5
|
SubComponent<{ events: { a: string } }, Wm.View>()({
|
|
6
6
|
watch: {
|
|
7
7
|
// @ts-expect-error 无可监控字段时,约束为EmptyObject,不可写任何字段
|
|
8
|
-
|
|
8
|
+
nothing() {},
|
|
9
9
|
},
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -14,7 +14,16 @@ SubComponent<{ events: { a: string } }, Wm.View>()({
|
|
|
14
14
|
*/
|
|
15
15
|
SubComponent<{ events: { a: string } }, Wm.View>()({
|
|
16
16
|
data: {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
view_style: "",
|
|
18
|
+
},
|
|
19
|
+
watch: {
|
|
20
|
+
view_style(newValue, oldValue) { // ok
|
|
21
|
+
newValue;
|
|
22
|
+
|
|
23
|
+
oldValue;
|
|
24
|
+
},
|
|
25
|
+
// @ts-expect-error 超出约束字段错误
|
|
26
|
+
view_XXstyle() {
|
|
27
|
+
},
|
|
19
28
|
},
|
|
20
29
|
});
|