annil 1.0.4 → 1.0.5
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 +8 -1
- package/README.md +79 -10
- package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.js +6 -6
- package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.js.map +1 -1
- package/dist/api/DefineComponent/ReturnType/test/normalPageDoc.test.js.map +1 -1
- package/dist/api/RootComponent/CustomEvents/CustomEventConstraint.d.ts +3 -3
- package/dist/api/RootComponent/CustomEvents/GetCustomEventDoc.d.ts +5 -5
- package/dist/api/RootComponent/CustomEvents/test/error.test.js +8 -8
- package/dist/api/RootComponent/CustomEvents/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/CustomEvents/test/normal.test.d.ts +17 -17
- package/dist/api/RootComponent/CustomEvents/test/normal.test.js +6 -6
- package/dist/api/RootComponent/CustomEvents/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.js +5 -5
- package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.js.map +1 -1
- package/dist/api/RootComponent/Instance/test/customEvents/normal.test.js +5 -5
- package/dist/api/RootComponent/Instance/test/customEvents/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Instance/test/properties/mormal.test.js.map +1 -1
- package/dist/api/RootComponent/PageLifetimes/test/normal.test.js.map +1 -1
- package/dist/api/RootComponent/Properties/GetOptionalDoc.d.ts +2 -2
- package/dist/api/RootComponent/Properties/GetRequiredDoc.d.ts +2 -2
- package/dist/api/RootComponent/Properties/PropertiesConstraint.d.ts +6 -6
- package/dist/api/RootComponent/Properties/PropertiesValueValidator.d.ts +2 -2
- package/dist/api/RootComponent/Properties/test/error.test.js.map +1 -1
- package/dist/api/RootComponent/Properties/test/normalRequired.test.d.ts +21 -21
- package/dist/api/SubComponent/SubComputed/GetSubComputedDoc.d.ts +1 -1
- package/dist/api/SubComponent/SubComputed/test/normal.test.js +4 -4
- package/dist/api/SubComponent/SubComputed/test/normal.test.js.map +1 -1
- package/dist/api/SubComponent/index.d.ts +1 -1
- package/dist/api/SubComponent/index.js.map +1 -1
- package/dist/api/navigateTo.d.ts +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/{SpecificType.d.ts → DetailedType.d.ts} +1 -1
- package/dist/types/DetailedType.js +2 -0
- package/dist/types/DetailedType.js.map +1 -0
- package/dist/types/GenerateDoc.d.ts +9 -0
- package/dist/types/GenerateDoc.js +2 -0
- package/dist/types/GenerateDoc.js.map +1 -0
- package/dist/types/InferDetailedType.d.ts +2 -0
- package/dist/types/InferDetailedType.js +2 -0
- package/dist/types/InferDetailedType.js.map +1 -0
- package/dist/types/{InferSpecificType.test.js → InferDetailedType.test.js} +1 -1
- package/dist/types/InferDetailedType.test.js.map +1 -0
- package/dist/types/OfficialTypeAlias.d.ts +4 -4
- package/package.json +1 -1
- package/src/api/DefineComponent/ReturnType/test/normalComponentDoc.test.ts +12 -12
- package/src/api/DefineComponent/ReturnType/test/normalPageDoc.test.ts +4 -4
- package/src/api/RootComponent/Computed/test/normal.test.ts +2 -2
- package/src/api/RootComponent/CustomEvents/CustomEventConstraint.ts +3 -3
- package/src/api/RootComponent/CustomEvents/CustomEventsOption.ts +2 -2
- package/src/api/RootComponent/CustomEvents/GetCustomEventDoc.ts +7 -7
- package/src/api/RootComponent/CustomEvents/test/error.test.ts +8 -8
- package/src/api/RootComponent/CustomEvents/test/normal.test.ts +9 -9
- package/src/api/RootComponent/Events/EventsConstraint.ts +1 -1
- package/src/api/RootComponent/Instance/test/CustomEventsDoc.test.ts +8 -8
- package/src/api/RootComponent/Instance/test/customEvents/normal.test.ts +8 -8
- package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +3 -3
- package/src/api/RootComponent/PageLifetimes/test/normal.test.ts +3 -3
- package/src/api/RootComponent/Properties/GetOptionalDoc.ts +5 -5
- package/src/api/RootComponent/Properties/GetRequiredDoc.ts +5 -5
- package/src/api/RootComponent/Properties/PropertiesConstraint.ts +6 -6
- package/src/api/RootComponent/Properties/PropertiesOption.ts +1 -1
- package/src/api/RootComponent/Properties/PropertiesValueValidator.ts +2 -2
- package/src/api/RootComponent/Properties/test/error.test.ts +2 -2
- package/src/api/RootComponent/Properties/test/normalOptional.test.ts +8 -8
- package/src/api/RootComponent/Properties/test/normalRequired.test.ts +11 -11
- package/src/api/RootComponent/Watch/test/WatchComputed.test.ts +2 -2
- package/src/api/RootComponent/Watch/test/WatchProperties.test.ts +4 -4
- package/src/api/SubComponent/SubComputed/test/normal.test.ts +15 -9
- package/src/api/SubComponent/index.ts +2 -1
- package/src/index.ts +11 -2
- package/src/types/DetailedType.ts +15 -0
- package/src/types/GenerateDoc.ts +19 -0
- package/src/types/InferDetailedType.test.ts +18 -0
- package/src/types/{InferSpecificType.ts → InferDetailedType.ts} +4 -4
- package/src/types/RestorePropertiesDoc.ts +3 -3
- package/tsconfig.json +2 -2
- package/dist/types/InferSpecificType.d.ts +0 -2
- package/dist/types/InferSpecificType.js +0 -2
- package/dist/types/InferSpecificType.js.map +0 -1
- package/dist/types/InferSpecificType.test.js.map +0 -1
- package/dist/types/SpecificType.js +0 -2
- package/dist/types/SpecificType.js.map +0 -1
- package/src/types/InferSpecificType.test.ts +0 -18
- package/src/types/SpecificType.ts +0 -15
- /package/dist/types/{InferSpecificType.test.d.ts → InferDetailedType.test.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DetailedType } from "../../../../types/DetailedType";
|
|
2
2
|
export type Mock_User = {
|
|
3
3
|
id: string;
|
|
4
4
|
age?: number;
|
|
@@ -13,12 +13,12 @@ export declare const mock_requiredSingle: {
|
|
|
13
13
|
bool: BooleanConstructor;
|
|
14
14
|
arr: ArrayConstructor;
|
|
15
15
|
obj: ObjectConstructor;
|
|
16
|
-
tuple:
|
|
17
|
-
union_str:
|
|
18
|
-
union_num:
|
|
19
|
-
union_bool:
|
|
20
|
-
union_arr:
|
|
21
|
-
union_obj:
|
|
16
|
+
tuple: DetailedType<[string, number, boolean]>;
|
|
17
|
+
union_str: DetailedType<"male" | "female">;
|
|
18
|
+
union_num: DetailedType<0 | 1 | 2>;
|
|
19
|
+
union_bool: DetailedType<boolean>;
|
|
20
|
+
union_arr: DetailedType<string[] | number[]>;
|
|
21
|
+
union_obj: DetailedType<Mock_User | Mock_Cart>;
|
|
22
22
|
};
|
|
23
23
|
export declare const mock_requiredUnion: {
|
|
24
24
|
union_str_num_bool: {
|
|
@@ -26,16 +26,16 @@ export declare const mock_requiredUnion: {
|
|
|
26
26
|
optionalTypes: (NumberConstructor | BooleanConstructor)[];
|
|
27
27
|
};
|
|
28
28
|
union_literalStr_Literalnum: {
|
|
29
|
-
type:
|
|
30
|
-
optionalTypes:
|
|
29
|
+
type: DetailedType<"male" | "female">;
|
|
30
|
+
optionalTypes: DetailedType<0 | 1 | 2>[];
|
|
31
31
|
};
|
|
32
32
|
union_mockUser_num: {
|
|
33
|
-
type:
|
|
33
|
+
type: DetailedType<Mock_User>;
|
|
34
34
|
optionalTypes: NumberConstructor[];
|
|
35
35
|
};
|
|
36
36
|
union_num_mockUser: {
|
|
37
37
|
type: NumberConstructor;
|
|
38
|
-
optionalTypes:
|
|
38
|
+
optionalTypes: DetailedType<Mock_User>[];
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
export declare const mock_requiredTypes: {
|
|
@@ -44,28 +44,28 @@ export declare const mock_requiredTypes: {
|
|
|
44
44
|
optionalTypes: (NumberConstructor | BooleanConstructor)[];
|
|
45
45
|
};
|
|
46
46
|
union_literalStr_Literalnum: {
|
|
47
|
-
type:
|
|
48
|
-
optionalTypes:
|
|
47
|
+
type: DetailedType<"male" | "female">;
|
|
48
|
+
optionalTypes: DetailedType<0 | 1 | 2>[];
|
|
49
49
|
};
|
|
50
50
|
union_mockUser_num: {
|
|
51
|
-
type:
|
|
51
|
+
type: DetailedType<Mock_User>;
|
|
52
52
|
optionalTypes: NumberConstructor[];
|
|
53
53
|
};
|
|
54
54
|
union_num_mockUser: {
|
|
55
55
|
type: NumberConstructor;
|
|
56
|
-
optionalTypes:
|
|
56
|
+
optionalTypes: DetailedType<Mock_User>[];
|
|
57
57
|
};
|
|
58
58
|
str: StringConstructor;
|
|
59
59
|
num: NumberConstructor;
|
|
60
60
|
bool: BooleanConstructor;
|
|
61
61
|
arr: ArrayConstructor;
|
|
62
62
|
obj: ObjectConstructor;
|
|
63
|
-
tuple:
|
|
64
|
-
union_str:
|
|
65
|
-
union_num:
|
|
66
|
-
union_bool:
|
|
67
|
-
union_arr:
|
|
68
|
-
union_obj:
|
|
63
|
+
tuple: DetailedType<[string, number, boolean]>;
|
|
64
|
+
union_str: DetailedType<"male" | "female">;
|
|
65
|
+
union_num: DetailedType<0 | 1 | 2>;
|
|
66
|
+
union_bool: DetailedType<boolean>;
|
|
67
|
+
union_arr: DetailedType<string[] | number[]>;
|
|
68
|
+
union_obj: DetailedType<Mock_User | Mock_Cart>;
|
|
69
69
|
};
|
|
70
70
|
type RequiredTypeExpected = {
|
|
71
71
|
str: string;
|
|
@@ -43,12 +43,9 @@ SubComponent()({
|
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
45
|
SubComponent()({
|
|
46
|
-
data: {
|
|
47
|
-
aaa_xxx: 123,
|
|
48
|
-
},
|
|
49
46
|
computed: {
|
|
50
47
|
aaa_num() {
|
|
51
|
-
return this.data.
|
|
48
|
+
return this.data.SNum;
|
|
52
49
|
},
|
|
53
50
|
aaa_user() {
|
|
54
51
|
return this.data.user;
|
|
@@ -56,6 +53,9 @@ SubComponent()({
|
|
|
56
53
|
aaa_age() {
|
|
57
54
|
return this.data.aaa_num;
|
|
58
55
|
},
|
|
56
|
+
aaa_str() {
|
|
57
|
+
return this.data.str;
|
|
58
|
+
},
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
61
|
//# sourceMappingURL=normal.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normal.test.js","sourceRoot":"","sources":["../../../../../src/api/SubComponent/SubComputed/test/normal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAKhD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"normal.test.js","sourceRoot":"","sources":["../../../../../src/api/SubComponent/SubComputed/test/normal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAKhD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AA4BrC,YAAY,EAAyB,CAAC;IAEpC,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC;AAWH,YAAY,EAA0B,CAAC;IACrC,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;KACf;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,GAAG;KACb;IAED,QAAQ,EAAE;QACR,OAAO;YACL,OAAO,EAAsB,CAAC;QAChC,CAAC;QACD,UAAU;YACR,OAAO,GAAG,CAAC;QACb,CAAC;KACF;CACF,CAAC,CAAC;AAEH,YAAY,EAA0B,CAAC;IACrC,QAAQ,EAAE;QACR,OAAO;YACL,OAAO,GAAa,CAAC;QACvB,CAAC;QACD,UAAU;YACR,OAAO,GAAG,CAAC;QACb,CAAC;QACD,OAAO;YACL,OAAO,GAAG,CAAC;QACb,CAAC;QACD,OAAO;YACL,IAAI,CAAC,IAAI,CAAC;YAGV,QAcC,CAAC;YAEF,OAAO,EAAe,CAAC;QACzB,CAAC;KACF;IACD,SAAS,EAAE;QACT,QAAQ;YAEN,QAcC,CAAC;QACJ,CAAC;KACF;CACF,CAAC,CAAC;AAIH,YAAY,EAAc,CAAC;IACzB,QAAQ,EAAE;QACR,OAAO;YACL,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QACxB,CAAC;QACD,QAAQ;YACN,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QACxB,CAAC;QACD,OAAO;YACL,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QAC3B,CAAC;QACD,OAAO;YACL,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QACvB,CAAC;KACF;CACF,CAAC,CAAC"}
|
|
@@ -27,7 +27,7 @@ import type { SubWatchOption } from "./SubWatch/SubWatchOption";
|
|
|
27
27
|
type Options<RootDoc extends RootComponentDoc, IsPage extends boolean, CurrentCompDoc extends ComponentDoc, Prefix extends string, AllRootDataDoc extends object, TInherit extends object, TSubData extends object, TSubStore extends object, TSubComputed extends object, TEvents extends object, TSubMethods extends object, InheritDoc extends object, SubDataDoc extends object, SubStoreDoc extends object, SubComputedDoc extends object, SubEventsDoc extends object, SubMethodsDoc extends object> = {
|
|
28
28
|
inherit?: TInherit;
|
|
29
29
|
} & SubDataOption<TSubData, Exclude<keyof CurrentCompDoc["properties"], (keyof InheritDoc)>, Prefix> & SubStoreOption<TSubStore, Exclude<keyof CurrentCompDoc["properties"], (keyof (InheritDoc & SubDataDoc))>, Prefix> & SubComputedOption<TSubComputed, Omit<CurrentCompDoc["properties"], (keyof (InheritDoc & SubDataDoc & SubStoreDoc))>> & SubEventsOption<TEvents, SubEventsDoc, keyof SubEventsConstraint<CurrentCompDoc>> & SubMethodsOption<TSubMethods, Prefix, keyof CurrentCompDoc["customEvents"]> & SubPageLifetimesOption<IsPage, RootDoc["properties"] & {}> & SubLifetimesOption & SubWatchOption<SubComputedDoc & SubDataDoc & AllRootDataDoc & SubStoreDoc> & Partial<Omit<WMCompOtherOption, "pageLifetimes">> & ThisType<SubInstance<SubMethodsDoc & RootDoc["methods"], TSubData, AllRootDataDoc & SubDataDoc & SubComputedDoc & SubStoreDoc, RootDoc["customEvents"] & {}, SubStoreDoc>>;
|
|
30
|
-
type SubComponentConstructor<TRootDoc extends RootComponentDoc, TOriginalCompDoc extends ComponentDoc, TSupplementalPrefix extends string = "", IsPage extends boolean = TRootDoc["isPage"] extends true ? true : false, CurrentPrefix extends string = `${ExtractDocPrefix<TOriginalCompDoc>}${Capitalize<TSupplementalPrefix>}`, CurrentCompDoc extends ComponentDoc = IfExtends<TSupplementalPrefix, "", TOriginalCompDoc, ReplacePrefix<TOriginalCompDoc, CurrentPrefix>>, AllRootDataDoc extends object = Required<TRootDoc["properties"]> & TRootDoc["data"] & TRootDoc["computed"]> = {
|
|
30
|
+
type SubComponentConstructor<TRootDoc extends RootComponentDoc, TOriginalCompDoc extends ComponentDoc, TSupplementalPrefix extends string = "", IsPage extends boolean = TRootDoc["isPage"] extends true ? true : false, CurrentPrefix extends string = `${ExtractDocPrefix<TOriginalCompDoc>}${Capitalize<TSupplementalPrefix>}`, CurrentCompDoc extends ComponentDoc = IfExtends<TSupplementalPrefix, "", TOriginalCompDoc, ReplacePrefix<TOriginalCompDoc, CurrentPrefix>>, AllRootDataDoc extends object = Required<TRootDoc["properties"]> & TRootDoc["data"] & TRootDoc["computed"] & TRootDoc["store"]> = {
|
|
31
31
|
<TInherit extends InheritConstraint<AllRootDataDoc, CurrentCompDoc>, TSubData extends SubDataConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof InheritDoc>>, TSubStore extends SubStoreConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc)>>, TEvents extends SubEventsConstraint<CurrentCompDoc>, TSubComputed extends SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)>>, TSubMethods extends SubMethodsConstraint = {}, InheritDoc extends object = IfExtends<InheritConstraint<AllRootDataDoc, CurrentCompDoc>, TInherit, {}, TInherit>, SubDataDoc extends object = IfExtends<SubDataConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof InheritDoc>>, TSubData, {}, TSubData>, SubStoreDoc extends object = IfExtends<SubStoreConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc)>>, TSubStore, {}, {
|
|
32
32
|
[k in keyof TSubStore]: ReturnType<TSubStore[k] & {}>;
|
|
33
33
|
}>, SubComputedDoc extends object = IfExtends<SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)>>, TSubComputed, {}, GetSubComputedDoc<TSubComputed>>, SubEventsDoc extends object = IfExtends<SubEventsConstraint<CurrentCompDoc>, TEvents, {}, TEvents>, SubMethodsDoc extends object = TSubMethods, MissingRequiredField extends PropertyKey = Exclude<RequiredKeys<CurrentCompDoc["properties"] & {}>, keyof (InheritDoc & SubDataDoc & SubStoreDoc & IfExtends<SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)>>, TSubComputed, {}, GetSubComputedDoc<TSubComputed>>)>>(options: Options<TRootDoc, IsPage, CurrentCompDoc, CurrentPrefix, AllRootDataDoc, TInherit, TSubData, TSubStore, TSubComputed, TEvents, TSubMethods, InheritDoc, SubDataDoc, SubStoreDoc, SubComputedDoc, SubEventsDoc, SubMethodsDoc>): CreateSubComponentDoc<TOriginalCompDoc["customEvents"] & {}, SubEventsDoc, MissingRequiredField>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/SubComponent/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/SubComponent/index.ts"],"names":[],"mappings":"AAkMA,MAAM,UAAU,YAAY;IAK1B,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAkC,CAAQ,CAAC;AACvE,CAAC"}
|
package/dist/api/navigateTo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference types="
|
|
1
|
+
/// <reference types="miniprogram-api-typings" />
|
|
2
2
|
import type { IfEquals } from "hry-types/src/Any/IfEquals";
|
|
3
3
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
4
4
|
import type { NoInfer } from "hry-types/src/Generic/NoInfer";
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { navigateTo } from "./api/navigateTo";
|
|
|
4
4
|
import { DefineComponent } from "./api/DefineComponent";
|
|
5
5
|
import { RootComponent } from "./api/RootComponent";
|
|
6
6
|
import { SubComponent } from "./api/SubComponent";
|
|
7
|
-
import type {
|
|
7
|
+
import type { DetailedType } from "./types/DetailedType";
|
|
8
|
+
import type { GenerateDoc } from "./types/GenerateDoc";
|
|
8
9
|
import type { ParamsEqual } from "./types/TwoParamsEqual";
|
|
9
|
-
export { DefineComponent,
|
|
10
|
+
export { DefineComponent, type DetailedType, type GenerateDoc, navigateTo, type ParamsEqual, RootComponent, SubComponent, };
|
package/dist/index.js
CHANGED
|
@@ -2,5 +2,5 @@ import { navigateTo } from "./api/navigateTo";
|
|
|
2
2
|
import { DefineComponent } from "./api/DefineComponent";
|
|
3
3
|
import { RootComponent } from "./api/RootComponent";
|
|
4
4
|
import { SubComponent } from "./api/SubComponent";
|
|
5
|
-
export { DefineComponent, navigateTo, RootComponent, SubComponent };
|
|
5
|
+
export { DefineComponent, navigateTo, RootComponent, SubComponent, };
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOlD,OAAO,EACL,eAAe,EAGf,UAAU,EAEV,aAAa,EACb,YAAY,GACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DetailedType.js","sourceRoot":"","sources":["../../src/types/DetailedType.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
3
|
+
import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
|
|
4
|
+
import type { AddPrefix } from "./AddPrefix";
|
|
5
|
+
export type GenerateDoc<TName extends string, T extends ComponentDoc> = ComputeIntersection<IfExtends<unknown, T["properties"], {}, {
|
|
6
|
+
properties: AddPrefix<T["properties"] & {}, TName>;
|
|
7
|
+
}> & IfExtends<unknown, T["customEvents"], {}, {
|
|
8
|
+
customEvents: AddPrefix<T["customEvents"] & {}, TName>;
|
|
9
|
+
}>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenerateDoc.js","sourceRoot":"","sources":["../../src/types/GenerateDoc.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { DetailedType } from "./DetailedType";
|
|
2
|
+
export type InferDetailedType<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends DetailedType<infer R> ? R : never;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InferDetailedType.js","sourceRoot":"","sources":["../../src/types/InferDetailedType.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InferDetailedType.test.js","sourceRoot":"","sources":["../../src/types/InferDetailedType.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAKhD,QAAiE,CAAC;AAElE,QAAiE,CAAC;AAElE,QAAmE,CAAC;AAEpE,QAAmE,CAAC;AAEpE,QAAiE,CAAC;AAElE,QAA0E,CAAC;AAE3E,QAA0G,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="
|
|
2
|
-
/// <reference types="
|
|
3
|
-
/// <reference types="
|
|
4
|
-
/// <reference types="
|
|
1
|
+
/// <reference types="miniprogram-api-typings" />
|
|
2
|
+
/// <reference types="miniprogram-api-typings" />
|
|
3
|
+
/// <reference types="miniprogram-api-typings" />
|
|
4
|
+
/// <reference types="miniprogram-api-typings" />
|
|
5
5
|
export type WMTriggerEventOption = WechatMiniprogram.Component.TriggerEventOption;
|
|
6
6
|
export type WMCustomEvent<Detail = undefined, Mark extends object = object, CurrentTargetDataset extends object = object, TargetDataset extends object = CurrentTargetDataset> = WechatMiniprogram.CustomEvent<Detail, Mark, CurrentTargetDataset, TargetDataset>;
|
|
7
7
|
export type WMBaseEvent<Mark extends object = object, CurrentTargetDataset extends object = object, TargetDataset extends object = CurrentTargetDataset> = WechatMiniprogram.BaseEvent<Mark, CurrentTargetDataset, TargetDataset>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
2
|
import { type ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
|
|
3
|
-
import {
|
|
3
|
+
import { type DetailedType, RootComponent } from "../../../..";
|
|
4
4
|
import type { CustomEventConstraint } from "../../../RootComponent/CustomEvents/CustomEventConstraint";
|
|
5
5
|
import type {
|
|
6
6
|
Bubbles,
|
|
@@ -20,43 +20,43 @@ import { DefineComponent } from "../..";
|
|
|
20
20
|
|
|
21
21
|
const properties = {
|
|
22
22
|
str: String,
|
|
23
|
-
obj: Object as
|
|
23
|
+
obj: Object as DetailedType<Mock_User>,
|
|
24
24
|
optionalObj: {
|
|
25
|
-
type: Object as
|
|
25
|
+
type: Object as DetailedType<Mock_User>,
|
|
26
26
|
value: {} as Mock_User,
|
|
27
27
|
},
|
|
28
28
|
optionalObjOrNull: {
|
|
29
|
-
type: Object as
|
|
29
|
+
type: Object as DetailedType<Mock_User | null>,
|
|
30
30
|
value: null,
|
|
31
31
|
},
|
|
32
32
|
} satisfies PropertiesConstraint;
|
|
33
33
|
const customEvents = {
|
|
34
34
|
str: String,
|
|
35
35
|
null: null,
|
|
36
|
-
unionStr: String as
|
|
37
|
-
list: [String, Number as
|
|
36
|
+
unionStr: String as DetailedType<"male" | "female">,
|
|
37
|
+
list: [String, Number as DetailedType<0 | 1 | 2>, null],
|
|
38
38
|
bubbles: {
|
|
39
|
-
|
|
39
|
+
detail: String,
|
|
40
40
|
options: { bubbles: true },
|
|
41
41
|
},
|
|
42
42
|
capturePhase: {
|
|
43
|
-
|
|
43
|
+
detail: null,
|
|
44
44
|
options: { capturePhase: true },
|
|
45
45
|
},
|
|
46
46
|
bubbles_capturePhase: {
|
|
47
|
-
|
|
47
|
+
detail: [String, Number],
|
|
48
48
|
options: { bubbles: true, capturePhase: true },
|
|
49
49
|
},
|
|
50
50
|
bubbles_composed: {
|
|
51
|
-
|
|
51
|
+
detail: String as DetailedType<"male" | "female">,
|
|
52
52
|
options: { bubbles: true, composed: true },
|
|
53
53
|
},
|
|
54
54
|
capturePhase_composed: {
|
|
55
|
-
|
|
55
|
+
detail: [String, Number as DetailedType<0 | 1 | 2>, null],
|
|
56
56
|
options: { capturePhase: true, composed: true },
|
|
57
57
|
},
|
|
58
58
|
bubbles_capturePhase_composed: {
|
|
59
|
-
|
|
59
|
+
detail: Boolean,
|
|
60
60
|
options: { bubbles: true, capturePhase: true, composed: true },
|
|
61
61
|
},
|
|
62
62
|
} satisfies CustomEventConstraint;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import {
|
|
2
|
+
import { type DetailedType, RootComponent } from "../../../..";
|
|
3
3
|
|
|
4
4
|
import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
|
|
5
5
|
import { DefineComponent } from "../..";
|
|
@@ -8,13 +8,13 @@ const OnlyPropsRootDoc = RootComponent()({
|
|
|
8
8
|
isPage: true,
|
|
9
9
|
properties: {
|
|
10
10
|
str: String,
|
|
11
|
-
obj: Object as
|
|
11
|
+
obj: Object as DetailedType<Mock_User>,
|
|
12
12
|
optionalObj: {
|
|
13
|
-
type: Object as
|
|
13
|
+
type: Object as DetailedType<Mock_User>,
|
|
14
14
|
value: {} as Mock_User,
|
|
15
15
|
},
|
|
16
16
|
optionalObjOrNull: {
|
|
17
|
-
type: Object as
|
|
17
|
+
type: Object as DetailedType<Mock_User | null>,
|
|
18
18
|
value: null,
|
|
19
19
|
},
|
|
20
20
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
2
|
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
|
-
import type {
|
|
3
|
+
import type { DetailedType } from "../../../../types/DetailedType";
|
|
4
4
|
import { RootComponent } from "../..";
|
|
5
5
|
import type { Mock_User } from "../../Properties/test/normalRequired.test";
|
|
6
6
|
|
|
@@ -88,7 +88,7 @@ Checking<typeof EmptyComputedFieldDoc, { methods: { M1: () => void } }, Test.Pas
|
|
|
88
88
|
RootComponent()({
|
|
89
89
|
isPage: true,
|
|
90
90
|
properties: {
|
|
91
|
-
obj: Object as
|
|
91
|
+
obj: Object as DetailedType<{ name: string; age: number }>,
|
|
92
92
|
},
|
|
93
93
|
computed: {
|
|
94
94
|
age() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DetailedType } from "../../../types/DetailedType";
|
|
2
2
|
|
|
3
|
-
type SimpleCustomeEvents =
|
|
3
|
+
type SimpleCustomeEvents = DetailedType | null;
|
|
4
4
|
|
|
5
5
|
export type SimpleCustomeEventsList = SimpleCustomeEvents[];
|
|
6
6
|
|
|
@@ -43,7 +43,7 @@ export type OptionsFieldsConfigOfCustomEvents =
|
|
|
43
43
|
* 带options的CustomEvents配置
|
|
44
44
|
*/
|
|
45
45
|
export type FullCustomEvents = {
|
|
46
|
-
|
|
46
|
+
detail: ShortCustomeEvents;
|
|
47
47
|
options: OptionsFieldsConfigOfCustomEvents;
|
|
48
48
|
};
|
|
49
49
|
|
|
@@ -17,9 +17,9 @@ export type CustomEventsOption<
|
|
|
17
17
|
* // ...
|
|
18
18
|
* customEvents: {
|
|
19
19
|
* A: Number, // number
|
|
20
|
-
* B: [String as
|
|
20
|
+
* B: [String as DetailedType<"male" | "femal">, Number], // "male" | "femal" | number
|
|
21
21
|
* C: {
|
|
22
|
-
*
|
|
22
|
+
* detail: String,
|
|
23
23
|
* options: {
|
|
24
24
|
* bubbles: true,
|
|
25
25
|
* composed: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { DetailedType } from "../../../types/DetailedType";
|
|
2
|
+
import type { InferDetailedType } from "../../../types/InferDetailedType";
|
|
3
3
|
import type {
|
|
4
4
|
CustomEventConstraint,
|
|
5
5
|
FullCustomEvents,
|
|
@@ -8,13 +8,13 @@ import type {
|
|
|
8
8
|
} from "./CustomEventConstraint";
|
|
9
9
|
import type { AddTagForCustomEventsDoc } from "./CustomEventsTag";
|
|
10
10
|
|
|
11
|
-
export type GetShortCustomEventsDoc<T extends ShortCustomeEvents> = T extends
|
|
11
|
+
export type GetShortCustomEventsDoc<T extends ShortCustomeEvents> = T extends DetailedType ? InferDetailedType<T>
|
|
12
12
|
: T extends null ? null
|
|
13
13
|
: T extends SimpleCustomeEventsList ? GetShortCustomEventsDoc<T[number]>
|
|
14
14
|
: never;
|
|
15
15
|
|
|
16
16
|
export type GetFullCustomEventsDoc<T extends FullCustomEvents> =
|
|
17
|
-
| GetShortCustomEventsDoc<T["
|
|
17
|
+
| GetShortCustomEventsDoc<T["detail"]>
|
|
18
18
|
| AddTagForCustomEventsDoc<T["options"]>;
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -23,8 +23,8 @@ export type GetFullCustomEventsDoc<T extends FullCustomEvents> =
|
|
|
23
23
|
* ```ts
|
|
24
24
|
* customEvents:{
|
|
25
25
|
* a:Number,
|
|
26
|
-
* b:{
|
|
27
|
-
* c:{
|
|
26
|
+
* b:{ detail: String,options:{ bubbles:true } }
|
|
27
|
+
* c:{ detail: Number,options:{ bubbles:true, composed:true } }
|
|
28
28
|
* }
|
|
29
29
|
* //result => {a:number,b:string|()=>'bubbles',c:number | ()=>'composed' }
|
|
30
30
|
* ```
|
|
@@ -36,7 +36,7 @@ export type GetCustomEventDoc<T extends CustomEventConstraint> =
|
|
|
36
36
|
[k in keyof T]: T[k] extends ShortCustomeEvents ? GetShortCustomEventsDoc<T[k]>
|
|
37
37
|
// 应该写GetFullCustomEventsDoc<T[k]>带鼠标悬停时不是计算结果。所以代码重复了。
|
|
38
38
|
: // @ts-ignore T[k] 一定为 FullCustomEvents 类型
|
|
39
|
-
| GetShortCustomEventsDoc<T[k]["
|
|
39
|
+
| GetShortCustomEventsDoc<T[k]["detail"]>
|
|
40
40
|
// 为自定义事件模型加标记,方便识别
|
|
41
41
|
// @ts-ignore T[k] 一定为 FullCustomEvents 类型
|
|
42
42
|
| AddTagForCustomEventsDoc<T[k]["options"]>;
|
|
@@ -7,26 +7,26 @@ RootComponent()({
|
|
|
7
7
|
customEvents: {
|
|
8
8
|
// @ts-expect-error options 没有options字段时无需写对象形式,应简写`error1:Boolean`。
|
|
9
9
|
error1: {
|
|
10
|
-
|
|
10
|
+
detail: Boolean,
|
|
11
11
|
},
|
|
12
12
|
// @ts-expect-error options 不可以为空对象 无意义
|
|
13
13
|
error2: {
|
|
14
|
-
|
|
14
|
+
detail: Boolean,
|
|
15
15
|
options: {},
|
|
16
16
|
},
|
|
17
17
|
// @ts-expect-error false字段不要写 默认就为false
|
|
18
18
|
error3: {
|
|
19
|
-
|
|
19
|
+
detail: Boolean,
|
|
20
20
|
options: { bubbles: false },
|
|
21
21
|
},
|
|
22
22
|
// @ts-expect-error false 字段不要写 默认false
|
|
23
23
|
error4: {
|
|
24
|
-
|
|
24
|
+
detail: Boolean,
|
|
25
25
|
options: { capturePhase: false },
|
|
26
26
|
},
|
|
27
27
|
// @ts-expect-error composed字段不可以单独开启,必须存在 bubbles或capturePhase字段为true时
|
|
28
28
|
error5: {
|
|
29
|
-
|
|
29
|
+
detail: Boolean,
|
|
30
30
|
options: { composed: true },
|
|
31
31
|
},
|
|
32
32
|
},
|
|
@@ -53,7 +53,7 @@ RootComponent()({
|
|
|
53
53
|
RootComponent()({
|
|
54
54
|
customEvents: {
|
|
55
55
|
error1: {
|
|
56
|
-
|
|
56
|
+
detail: String,
|
|
57
57
|
options: {
|
|
58
58
|
bubbles: true,
|
|
59
59
|
// @ts-expect-error 非法字段 composed 少了d
|
|
@@ -69,7 +69,7 @@ RootComponent()({
|
|
|
69
69
|
RootComponent()({
|
|
70
70
|
customEvents: {
|
|
71
71
|
error2: {
|
|
72
|
-
|
|
72
|
+
detail: String,
|
|
73
73
|
options: {
|
|
74
74
|
bubbles: true,
|
|
75
75
|
// @ts-expect-error 非法字段 capturePhases 多了 s
|
|
@@ -90,7 +90,7 @@ RootComponent()({
|
|
|
90
90
|
},
|
|
91
91
|
customEvents: {
|
|
92
92
|
bbb: {
|
|
93
|
-
|
|
93
|
+
detail: null,
|
|
94
94
|
options: {
|
|
95
95
|
// @ts-expect-error 非法字段
|
|
96
96
|
bubbleds: false,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import {
|
|
2
|
+
import { type DetailedType, RootComponent } from "../../../..";
|
|
3
3
|
import type { CustomEventConstraint, FullCustomEvents, ShortCustomeEvents } from "../CustomEventConstraint";
|
|
4
4
|
import type {
|
|
5
5
|
Bubbles,
|
|
@@ -16,8 +16,8 @@ import type {
|
|
|
16
16
|
export const mock_shortCustomEvents = {
|
|
17
17
|
str: String,
|
|
18
18
|
null: null,
|
|
19
|
-
unionStr: String as
|
|
20
|
-
union: [String, Number as
|
|
19
|
+
unionStr: String as DetailedType<"male" | "female">,
|
|
20
|
+
union: [String, Number as DetailedType<0 | 1 | 2>, null],
|
|
21
21
|
} satisfies Record<string, ShortCustomeEvents>;
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -25,27 +25,27 @@ export const mock_shortCustomEvents = {
|
|
|
25
25
|
*/
|
|
26
26
|
export const mock_fullCustomEvents = {
|
|
27
27
|
bubbles: {
|
|
28
|
-
|
|
28
|
+
detail: String,
|
|
29
29
|
options: { bubbles: true },
|
|
30
30
|
},
|
|
31
31
|
capturePhase: {
|
|
32
|
-
|
|
32
|
+
detail: null,
|
|
33
33
|
options: { capturePhase: true },
|
|
34
34
|
},
|
|
35
35
|
bubbles_capturePhase: {
|
|
36
|
-
|
|
36
|
+
detail: [String, Number],
|
|
37
37
|
options: { bubbles: true, capturePhase: true },
|
|
38
38
|
},
|
|
39
39
|
bubbles_composed: {
|
|
40
|
-
|
|
40
|
+
detail: String as DetailedType<"male" | "female">,
|
|
41
41
|
options: { bubbles: true, composed: true },
|
|
42
42
|
},
|
|
43
43
|
capturePhase_composed: {
|
|
44
|
-
|
|
44
|
+
detail: [String, Number as DetailedType<0 | 1 | 2>, null],
|
|
45
45
|
options: { capturePhase: true, composed: true },
|
|
46
46
|
},
|
|
47
47
|
bubbles_capturePhase_composed: {
|
|
48
|
-
|
|
48
|
+
detail: Boolean,
|
|
49
49
|
options: { bubbles: true, capturePhase: true, composed: true },
|
|
50
50
|
},
|
|
51
51
|
} satisfies Record<string, FullCustomEvents>;
|
|
@@ -46,7 +46,7 @@ type TransformCustomEventsDocTypeToFunctionTypeAndAddSuffix<T extends CustomEven
|
|
|
46
46
|
) => void;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
// 所有子组件自定义事件(过滤掉非冒泡或捕获)的key加入后缀并把值(
|
|
49
|
+
// 所有子组件自定义事件(过滤掉非冒泡或捕获)的key加入后缀并把值(detail)转换为函数类型
|
|
50
50
|
type GetAllSubCustomEventsConstraint<TReceivedComponentDoc extends ComponentDoc[] | ComponentDoc> = {} extends
|
|
51
51
|
TReceivedComponentDoc ? {}
|
|
52
52
|
: TReceivedComponentDoc extends ComponentDoc[] ? TransformCustomEventsDocTypeToFunctionTypeAndAddSuffix<
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DetailedType } from "../../../..";
|
|
3
3
|
import { RootComponent } from "../..";
|
|
4
4
|
RootComponent()({
|
|
5
5
|
customEvents: {
|
|
6
6
|
str: String,
|
|
7
|
-
num: Number as
|
|
8
|
-
union: [String as
|
|
7
|
+
num: Number as DetailedType<1 | 2>,
|
|
8
|
+
union: [String as DetailedType<"male" | "femal">, Number],
|
|
9
9
|
null: null,
|
|
10
10
|
bubbles: {
|
|
11
|
-
|
|
11
|
+
detail: String,
|
|
12
12
|
options: {
|
|
13
13
|
bubbles: true,
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
capturePhase: {
|
|
17
|
-
|
|
17
|
+
detail: Number,
|
|
18
18
|
options: {
|
|
19
19
|
capturePhase: true,
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
22
|
bubblesComposed: {
|
|
23
|
-
|
|
23
|
+
detail: Number,
|
|
24
24
|
options: {
|
|
25
25
|
bubbles: true,
|
|
26
26
|
composed: true,
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
29
|
capturePhaseComposed: {
|
|
30
|
-
|
|
30
|
+
detail: Number,
|
|
31
31
|
options: {
|
|
32
32
|
capturePhase: true,
|
|
33
33
|
composed: true,
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
bubblesCapturePhaseComposed: {
|
|
37
|
-
|
|
37
|
+
detail: null,
|
|
38
38
|
options: {
|
|
39
39
|
bubbles: true,
|
|
40
40
|
capturePhase: true,
|