annil 1.5.12 → 1.5.13
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/RootComponent/CustomEvents/GetCustomEventDoc.d.ts +2 -1
- package/package.json +1 -1
- package/src/api/RootComponent/CustomEvents/GetCustomEventDoc.ts +3 -1
- package/src/api/RootComponent/CustomEvents/test/GetCustomEventDoc.test.ts +8 -1
- package/src/api/RootComponent/CustomEvents/test/GetShortEventDoc.test.ts +8 -0
- package/src/api/RootComponent/CustomEvents/test/normal.test.ts +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
* 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
|
|
6
6
|
|
|
7
|
+
## [1.5.13](https://github.com/missannil/annil/compare/v1.5.12...v1.5.13) (2024-01-12)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* 修改自定义事件detail类型为ReadOnlyDeep,以便调用时可传入实例中的data类型(都是ReadOnlyDeep的) ([428710e](https://github.com/missannil/annil/commit/428710ea84717c45361d1e6c9c7db46c693026a9))
|
|
13
|
+
|
|
7
14
|
## [1.5.12](https://github.com/missannil/annil/compare/v1.5.11...v1.5.12) (2024-01-12)
|
|
8
15
|
|
|
9
16
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
|
|
1
2
|
import type { DetailedType } from "../../../types/DetailedType";
|
|
2
3
|
import type { InferDetailedType } from "../../../types/InferDetailedType";
|
|
3
4
|
import type { CustomEventConstraint, FullCustomEvents, ShortCustomeEvents, SimpleCustomeEventsList } from "./CustomEventConstraint";
|
|
4
5
|
import type { AddTagForCustomEventsDoc } from "./CustomEventsTag";
|
|
5
|
-
export type GetShortCustomEventsDoc<T extends ShortCustomeEvents> = T extends DetailedType ? InferDetailedType<T
|
|
6
|
+
export type GetShortCustomEventsDoc<T extends ShortCustomeEvents> = T extends DetailedType ? ReadonlyDeep<InferDetailedType<T>> : T extends null ? null : T extends undefined ? undefined : T extends SimpleCustomeEventsList ? GetShortCustomEventsDoc<T[number]> : never;
|
|
6
7
|
export type GetFullCustomEventsDoc<T extends FullCustomEvents> = GetShortCustomEventsDoc<T["detail"]> | AddTagForCustomEventsDoc<T["options"]>;
|
|
7
8
|
export type GetCustomEventDoc<T extends CustomEventConstraint> = {
|
|
8
9
|
[k in keyof T]: T[k] extends ShortCustomeEvents ? GetShortCustomEventsDoc<T[k]> : GetShortCustomEventsDoc<T[k]["detail"]> | AddTagForCustomEventsDoc<T[k]["options"]>;
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
|
|
1
2
|
import type { DetailedType } from "../../../types/DetailedType";
|
|
2
3
|
import type { InferDetailedType } from "../../../types/InferDetailedType";
|
|
3
4
|
import type {
|
|
@@ -8,7 +9,8 @@ import type {
|
|
|
8
9
|
} from "./CustomEventConstraint";
|
|
9
10
|
import type { AddTagForCustomEventsDoc } from "./CustomEventsTag";
|
|
10
11
|
|
|
11
|
-
export type GetShortCustomEventsDoc<T extends ShortCustomeEvents> = T extends DetailedType
|
|
12
|
+
export type GetShortCustomEventsDoc<T extends ShortCustomeEvents> = T extends DetailedType
|
|
13
|
+
? ReadonlyDeep<InferDetailedType<T>>
|
|
12
14
|
: T extends null ? null
|
|
13
15
|
: T extends undefined ? undefined
|
|
14
16
|
: T extends SimpleCustomeEventsList ? GetShortCustomEventsDoc<T[number]>
|
|
@@ -9,7 +9,13 @@ import {
|
|
|
9
9
|
type CapturePhaseComposedExpected,
|
|
10
10
|
type CapturePhaseExpected,
|
|
11
11
|
} from "./GetFullEventDoc.test";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
type ListExpected,
|
|
14
|
+
type NullExpected,
|
|
15
|
+
type ObjExpected,
|
|
16
|
+
type StrExpected,
|
|
17
|
+
type UnionStrExpected,
|
|
18
|
+
} from "./GetShortEventDoc.test";
|
|
13
19
|
import { mock_customEvents } from "./normal.test";
|
|
14
20
|
|
|
15
21
|
type Mock_CustomEventsDoc = GetCustomEventDoc<typeof mock_customEvents>;
|
|
@@ -20,6 +26,7 @@ export type Mock_CustomEventsDocExpected = {
|
|
|
20
26
|
nothing: undefined;
|
|
21
27
|
unionStr: UnionStrExpected;
|
|
22
28
|
union: ListExpected;
|
|
29
|
+
obj: ObjExpected;
|
|
23
30
|
bubbles: bubblesExpected;
|
|
24
31
|
capturePhase: CapturePhaseExpected;
|
|
25
32
|
bubbles_capturePhase: BubblesCapturePhaseExpected;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
2
|
|
|
3
|
+
import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
|
|
4
|
+
import type { Mock_User } from "../../Properties/test/normalRequired.test";
|
|
3
5
|
import type { GetShortCustomEventsDoc } from "../GetCustomEventDoc";
|
|
4
6
|
import { mock_shortCustomEvents } from "./normal.test";
|
|
5
7
|
|
|
@@ -26,3 +28,9 @@ type ListResult = GetShortCustomEventsDoc<typeof mock_shortCustomEvents["union"]
|
|
|
26
28
|
export type ListExpected = string | 0 | 1 | 2 | null;
|
|
27
29
|
|
|
28
30
|
Checking<ListResult, ListExpected, Test.Pass>;
|
|
31
|
+
|
|
32
|
+
type ObjResult = GetShortCustomEventsDoc<typeof mock_shortCustomEvents["obj"]>;
|
|
33
|
+
|
|
34
|
+
export type ObjExpected = ReadonlyDeep<Mock_User>;
|
|
35
|
+
|
|
36
|
+
Checking<ObjResult, ObjExpected, Test.Pass>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
+
import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
|
|
2
3
|
import { type DetailedType, RootComponent } from "../../../..";
|
|
4
|
+
import type { Mock_User } from "../../Properties/test/normalRequired.test";
|
|
3
5
|
import type { CustomEventConstraint, FullCustomEvents, ShortCustomeEvents } from "../CustomEventConstraint";
|
|
4
6
|
import type {
|
|
5
7
|
Bubbles,
|
|
@@ -19,6 +21,7 @@ export const mock_shortCustomEvents = {
|
|
|
19
21
|
null: null,
|
|
20
22
|
unionStr: String as DetailedType<"male" | "female">,
|
|
21
23
|
union: [String, Number as DetailedType<0 | 1 | 2>, null],
|
|
24
|
+
obj: Object as DetailedType<Mock_User>,
|
|
22
25
|
} satisfies Record<string, ShortCustomeEvents>;
|
|
23
26
|
|
|
24
27
|
/**
|
|
@@ -68,6 +71,7 @@ type RootDoc = {
|
|
|
68
71
|
nothing: undefined;
|
|
69
72
|
unionStr: "male" | "female";
|
|
70
73
|
union: string | 0 | 1 | 2 | null;
|
|
74
|
+
obj: ReadonlyDeep<Mock_User>;
|
|
71
75
|
// 带options字段 通过联合类型加入。
|
|
72
76
|
bubbles: string | Bubbles;
|
|
73
77
|
capturePhase: null | Capture;
|
|
@@ -92,3 +96,22 @@ const rootDocNoFields = RootComponent()({});
|
|
|
92
96
|
|
|
93
97
|
// 3. 无customEvents字段时,Doc中无customEvents字段
|
|
94
98
|
Checking<typeof rootDocNoFields, {}, Test.Pass>;
|
|
99
|
+
|
|
100
|
+
// 4 实例中的对象数组都是readOnlyDeep类型,可以传递给自定义做参数
|
|
101
|
+
RootComponent()({
|
|
102
|
+
properties: {
|
|
103
|
+
obj: Object as DetailedType<Mock_User>,
|
|
104
|
+
},
|
|
105
|
+
data: {
|
|
106
|
+
obj1: {} as Mock_User,
|
|
107
|
+
_ddd: {} as Mock_User,
|
|
108
|
+
},
|
|
109
|
+
customEvents: mock_customEvents,
|
|
110
|
+
events: {
|
|
111
|
+
ddd() {
|
|
112
|
+
this.obj(this.data.obj!);
|
|
113
|
+
|
|
114
|
+
this.obj(this.data.obj1);
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
});
|