annil 1.5.8 → 1.5.9
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/InstanceInject/instanceConfig.d.ts +1 -1
- package/dist/api/InstanceInject/instanceConfig.js.map +1 -1
- package/dist/api/SubComponent/index.d.ts +2 -1
- package/dist/api/SubComponent/index.js.map +1 -1
- package/dist/types/AssignValues.d.ts +9 -0
- package/dist/types/AssignValues.js +2 -0
- package/dist/types/AssignValues.js.map +1 -0
- package/package.json +1 -1
- package/src/api/InstanceInject/instanceConfig.ts +2 -1
- package/src/api/SubComponent/SubComputed/test/normal.test.ts +5 -5
- package/src/api/SubComponent/SubData/test/normal.test.ts +3 -3
- package/src/api/SubComponent/SubInstance/test/normal.test.ts +2 -2
- package/src/api/SubComponent/index.ts +3 -2
- package/src/types/AssignValues.ts +26 -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.9](https://github.com/missannil/annil/compare/v1.5.8...v1.5.9) (2024-01-06)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* 无注入数据时 watch监控类型错误的问题和SubComponentdata数据为字面量类型造成实例类型错误的问题 ([3cb2b90](https://github.com/missannil/annil/commit/3cb2b9069a9aa0f95767a346f16634d4db3109f9))
|
|
13
|
+
|
|
7
14
|
## [1.5.8](https://github.com/missannil/annil/compare/v1.5.7...v1.5.8) (2024-01-05)
|
|
8
15
|
|
|
9
16
|
|
|
@@ -13,7 +13,7 @@ interface BaseInjectInfo {
|
|
|
13
13
|
export interface IInjectInfo extends BaseInjectInfo {
|
|
14
14
|
}
|
|
15
15
|
export type IInjectData = IInjectInfo["data"] & ReturnTypeInObject<IInjectInfo["store"]>;
|
|
16
|
-
export type IInjectStore = ReturnTypeInObject<IInjectInfo["store"]>;
|
|
16
|
+
export type IInjectStore = StoreConstraint extends IInjectInfo["store"] ? unknown : ReturnTypeInObject<IInjectInfo["store"]>;
|
|
17
17
|
export type IInjectMethods = IInjectInfo["methods"];
|
|
18
18
|
declare class InstanceConfig {
|
|
19
19
|
private info;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instanceConfig.js","sourceRoot":"","sources":["../../../src/api/InstanceInject/instanceConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instanceConfig.js","sourceRoot":"","sources":["../../../src/api/InstanceInject/instanceConfig.ts"],"names":[],"mappings":"AA+BA,MAAM,cAAc;IAApB;QACU,SAAI,GAAiC,EAAE,CAAC;IAOlD,CAAC;IANC,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;IAC9B,CAAC;IACM,aAAa,CAAC,IAA6B;QAChD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -5,6 +5,7 @@ import type { GetComponentPrefix } from "../../types/GetComponentPrefix";
|
|
|
5
5
|
import type { ReplacePrefix } from "../../types/ReplacePrefix";
|
|
6
6
|
import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
7
7
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
8
|
+
import type { AssignValues } from "../../types/AssignValues";
|
|
8
9
|
import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
|
|
9
10
|
import type { IInjectStore } from "../InstanceInject/instanceConfig";
|
|
10
11
|
import type { ComputedConstraint } from "../RootComponent/Computed/ComputedConstraint";
|
|
@@ -34,7 +35,7 @@ import type { CreateSubComponentDoc } from "./SubReturnType/CreateSubComponentDo
|
|
|
34
35
|
import type { SubStoreConstraint } from "./SubStore/SubStoreConstraint";
|
|
35
36
|
import type { SubStoreOption } from "./SubStore/SubStoreOption";
|
|
36
37
|
import type { SubWatchOption } from "./SubWatch/SubWatchOption";
|
|
37
|
-
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 SubMethodsConstraint, InheritDoc extends object, SubDataDoc extends object, SubStoreDoc extends object, SubComputedDoc extends object, SubEventsDoc extends object, SubMethodsDoc extends object> = SubInheritOption<TInherit> & SubDataOption<TSubData, Exclude<keyof CurrentCompDoc["properties"], (keyof InheritDoc)>, Prefix> & SubStoreOption<TSubStore, Exclude<keyof CurrentCompDoc["properties"], (keyof (InheritDoc & SubDataDoc))>> & SubComputedOption<TSubComputed, Omit<CurrentCompDoc["properties"], (keyof (InheritDoc & SubDataDoc & SubStoreDoc))>> & SubEventsOption<TEvents, SubEventsDoc, keyof SubEventsConstraint<CurrentCompDoc>> & SubMethodsOption<TSubMethods, Prefix, keyof (CurrentCompDoc["customEvents"] & SubEventsDoc)> & SubPageLifetimesOption<IsPage, RootDoc["properties"] & {}> & SubLifetimesOption & SubWatchOption<SubComputedDoc & SubDataDoc & AllRootDataDoc & SubStoreDoc & IInjectStore> & Partial<Omit<WMCompOtherOption, "pageLifetimes" | "definitionFilter" | "export" | "observers" | "relations">> & SubObserversOption<SubComputedDoc & SubDataDoc & AllRootDataDoc & SubStoreDoc & IInjectStore> & ThisType<SubInstance<SubMethodsDoc & RootDoc["methods"],
|
|
38
|
+
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 SubMethodsConstraint, InheritDoc extends object, SubDataDoc extends object, SubStoreDoc extends object, SubComputedDoc extends object, SubEventsDoc extends object, SubMethodsDoc extends object> = SubInheritOption<TInherit> & SubDataOption<TSubData, Exclude<keyof CurrentCompDoc["properties"], (keyof InheritDoc)>, Prefix> & SubStoreOption<TSubStore, Exclude<keyof CurrentCompDoc["properties"], (keyof (InheritDoc & SubDataDoc))>> & SubComputedOption<TSubComputed, Omit<CurrentCompDoc["properties"], (keyof (InheritDoc & SubDataDoc & SubStoreDoc))>> & SubEventsOption<TEvents, SubEventsDoc, keyof SubEventsConstraint<CurrentCompDoc>> & SubMethodsOption<TSubMethods, Prefix, keyof (CurrentCompDoc["customEvents"] & SubEventsDoc)> & SubPageLifetimesOption<IsPage, RootDoc["properties"] & {}> & SubLifetimesOption & SubWatchOption<SubComputedDoc & SubDataDoc & AllRootDataDoc & SubStoreDoc & IInjectStore> & Partial<Omit<WMCompOtherOption, "pageLifetimes" | "definitionFilter" | "export" | "observers" | "relations">> & SubObserversOption<SubComputedDoc & SubDataDoc & AllRootDataDoc & SubStoreDoc & IInjectStore> & ThisType<SubInstance<SubMethodsDoc & RootDoc["methods"], SubDataDoc, AllRootDataDoc & AssignValues<SubDataDoc & SubComputedDoc & SubStoreDoc, Required<CurrentCompDoc["properties"]>>, RootDoc["customEvents"] & {}, SubStoreDoc>>;
|
|
38
39
|
type SubComponentConstructor<TRootDoc extends RootComponentDoc, TOriginalCompDoc extends ComponentDoc, TSupplementalPrefix extends string = "", IsPage extends boolean = TRootDoc["isPage"] extends true ? true : false, CurrentPrefix extends string = `${GetComponentPrefix<TOriginalCompDoc>}${Capitalize<TSupplementalPrefix>}`, CurrentCompDoc extends ComponentDoc = IfExtends<TSupplementalPrefix, "", TOriginalCompDoc, ReplacePrefix<TOriginalCompDoc, CurrentPrefix>>, AllRootDataDoc extends object = Required<TRootDoc["properties"]> & TRootDoc["data"] & TRootDoc["computed"] & TRootDoc["store"]> = {
|
|
39
40
|
<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, {}, {
|
|
40
41
|
[k in keyof TSubStore]: ReturnType<TSubStore[k] & {}>;
|
|
@@ -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":"AAkNA,MAAM,UAAU,YAAY;IAK1B,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAkC,CAAQ,CAAC;AACvE,CAAC"}
|
|
@@ -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
|
+
type _AssignValues<Target, Source, UniqueKey extends keyof Target> = ComputeIntersection<{
|
|
4
|
+
[k in UniqueKey]: Target[k];
|
|
5
|
+
} & {
|
|
6
|
+
[k in Exclude<keyof Target, UniqueKey>]: Source[k];
|
|
7
|
+
}>;
|
|
8
|
+
export type AssignValues<Target, Source> = IfExtends<unknown, Target, unknown, _AssignValues<Target, Source, Exclude<keyof Target, keyof Source>>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssignValues.js","sourceRoot":"","sources":["../../src/types/AssignValues.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -21,7 +21,8 @@ export interface IInjectInfo extends BaseInjectInfo {
|
|
|
21
21
|
|
|
22
22
|
export type IInjectData = IInjectInfo["data"] & ReturnTypeInObject<IInjectInfo["store"]>;
|
|
23
23
|
|
|
24
|
-
export type IInjectStore =
|
|
24
|
+
export type IInjectStore = StoreConstraint extends IInjectInfo["store"] ? unknown
|
|
25
|
+
: ReturnTypeInObject<IInjectInfo["store"]>;
|
|
25
26
|
|
|
26
27
|
export type IInjectMethods = IInjectInfo["methods"];
|
|
27
28
|
|
|
@@ -67,7 +67,7 @@ SubComponent<Root, OnlyPropsCompDoc>()({
|
|
|
67
67
|
SubComponent<Root, OnlyPropsCompDoc>()({
|
|
68
68
|
computed: {
|
|
69
69
|
aaa_num() {
|
|
70
|
-
return 123
|
|
70
|
+
return 123;
|
|
71
71
|
},
|
|
72
72
|
aaa_num123(): 123 {
|
|
73
73
|
return 123;
|
|
@@ -90,8 +90,8 @@ SubComponent<Root, OnlyPropsCompDoc>()({
|
|
|
90
90
|
bool: boolean;
|
|
91
91
|
aaa_num: number;
|
|
92
92
|
aaa_num123: 123;
|
|
93
|
-
aaa_str: "a";
|
|
94
|
-
aaa_obj: Mock_User;
|
|
93
|
+
aaa_str: "a" | "b";
|
|
94
|
+
aaa_obj: Mock_User | null;
|
|
95
95
|
} & IInjectData
|
|
96
96
|
>,
|
|
97
97
|
Test.Pass
|
|
@@ -114,8 +114,8 @@ SubComponent<Root, OnlyPropsCompDoc>()({
|
|
|
114
114
|
bool: boolean;
|
|
115
115
|
aaa_num: number;
|
|
116
116
|
aaa_num123: 123;
|
|
117
|
-
aaa_str: "a";
|
|
118
|
-
aaa_obj: Mock_User;
|
|
117
|
+
aaa_str: "a" | "b";
|
|
118
|
+
aaa_obj: Mock_User | null;
|
|
119
119
|
} & IInjectData
|
|
120
120
|
>,
|
|
121
121
|
Test.Pass
|
|
@@ -54,10 +54,10 @@ SubComponent<{}, CompDoc>()({
|
|
|
54
54
|
typeof this.data,
|
|
55
55
|
ReadonlyDeep<
|
|
56
56
|
{
|
|
57
|
-
aaa_str: "a";
|
|
58
|
-
aaa_num: 123;
|
|
59
|
-
aaa_obj: null;
|
|
60
57
|
_aaa_str: string;
|
|
58
|
+
aaa_str: "a" | "b";
|
|
59
|
+
aaa_num: number;
|
|
60
|
+
aaa_obj: Mock_User | null;
|
|
61
61
|
} & IInjectData
|
|
62
62
|
>,
|
|
63
63
|
Test.Pass
|
|
@@ -6,6 +6,7 @@ import type { ReplacePrefix } from "../../types/ReplacePrefix";
|
|
|
6
6
|
import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
7
7
|
|
|
8
8
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
9
|
+
import type { AssignValues } from "../../types/AssignValues";
|
|
9
10
|
import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
|
|
10
11
|
import type { IInjectStore } from "../InstanceInject/instanceConfig";
|
|
11
12
|
import type { ComputedConstraint } from "../RootComponent/Computed/ComputedConstraint";
|
|
@@ -94,8 +95,8 @@ type Options<
|
|
|
94
95
|
& ThisType<
|
|
95
96
|
SubInstance<
|
|
96
97
|
SubMethodsDoc & RootDoc["methods"],
|
|
97
|
-
|
|
98
|
-
AllRootDataDoc & SubDataDoc & SubComputedDoc & SubStoreDoc,
|
|
98
|
+
SubDataDoc,
|
|
99
|
+
AllRootDataDoc & AssignValues<SubDataDoc & SubComputedDoc & SubStoreDoc, Required<CurrentCompDoc["properties"]>>,
|
|
99
100
|
RootDoc["customEvents"] & {},
|
|
100
101
|
SubStoreDoc
|
|
101
102
|
>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
|
+
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
3
|
+
|
|
4
|
+
type _AssignValues<Target, Source, UniqueKey extends keyof Target> = ComputeIntersection<
|
|
5
|
+
& { [k in UniqueKey]: Target[k] }
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
& { [k in Exclude<keyof Target, UniqueKey>]: Source[k] }
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Target与Source相同的key类型变为Source的类型
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* type obj = { a: "a"; b: "b"; c: boolean };
|
|
15
|
+
* type obj2 = { a: number; b: string; d: number };
|
|
16
|
+
* type test = AssignValues<obj, obj2>;
|
|
17
|
+
* // test = { a: number; b: string; c: boolean}
|
|
18
|
+
* type test1 = AssignValues<unknown, obj2>; // unknown
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export type AssignValues<Target, Source> = IfExtends<
|
|
22
|
+
unknown,
|
|
23
|
+
Target,
|
|
24
|
+
unknown,
|
|
25
|
+
_AssignValues<Target, Source, Exclude<keyof Target, keyof Source>>
|
|
26
|
+
>;
|