annil 1.0.5 → 1.0.6

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 CHANGED
@@ -4,6 +4,13 @@
4
4
 
5
5
  * 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
6
6
 
7
+ ## [1.0.6](https://github.com/missannil/annil/compare/v1.0.5...v1.0.6) (2023-12-02)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * 修复 properties对象字段为字面量类型时value类型不匹配的问题 ([faa5c96](https://github.com/missannil/annil/commit/faa5c96c0c0af8112b7828911cc0d40f56903669))
13
+
7
14
  ## [1.0.5](https://github.com/missannil/annil/compare/v1.0.4...v1.0.5) (2023-12-02)
8
15
 
9
16
 
@@ -1,9 +1,9 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
2
  import type { Select } from "hry-types/src/Object/Select";
3
- import type { ComputeIntersection } from "hry-types/src/Object/_api";
3
+ import type { ComputeIntersection, NonReadonlyDeep } from "hry-types/src/Object/_api";
4
4
  import type { GetOptionalDoc } from "./GetOptionalDoc";
5
5
  import type { GetRequiredDoc } from "./GetRequiredDoc";
6
6
  import type { OptionalType, PropertiesConstraint } from "./PropertiesConstraint";
7
- type _GetPropertiesDoc<TProperties extends PropertiesConstraint, TIsPage extends boolean, Type extends "Required" | "Optional" | "all" = "all", OptionalDoc = GetOptionalDoc<Select<TProperties, OptionalType>, TIsPage>, RequiredDoc = GetRequiredDoc<Omit<TProperties, keyof OptionalDoc>, TIsPage>> = IfExtends<Type, "all", ComputeIntersection<OptionalDoc & RequiredDoc>, IfExtends<Type, "Optional", OptionalDoc, RequiredDoc>>;
7
+ type _GetPropertiesDoc<TProperties extends PropertiesConstraint, TIsPage extends boolean, Type extends "Required" | "Optional" | "all" = "all", OptionalDoc = NonReadonlyDeep<GetOptionalDoc<Select<TProperties, OptionalType>, TIsPage>>, RequiredDoc = NonReadonlyDeep<GetRequiredDoc<Omit<TProperties, keyof OptionalDoc>, TIsPage>>> = IfExtends<Type, "all", ComputeIntersection<OptionalDoc & RequiredDoc>, IfExtends<Type, "Optional", OptionalDoc, RequiredDoc>>;
8
8
  export type GetPropertiesDoc<TProperties extends PropertiesConstraint, TisPage extends boolean, Type extends "Required" | "Optional" | "all" = "all"> = _GetPropertiesDoc<TProperties, TisPage, Type>;
9
9
  export {};
@@ -1,14 +1,14 @@
1
1
  import type { DetailedType } from "../../../types/DetailedType";
2
2
  export type RequiredSingle = DetailedType;
3
- export type RequiredUnion<Literal = unknown> = {
4
- type: DetailedType<Literal>;
3
+ export type RequiredUnion = {
4
+ type: DetailedType;
5
5
  optionalTypes: DetailedType[];
6
6
  };
7
- export type RequiredType<Literal = unknown> = RequiredUnion<Literal> | RequiredSingle;
8
- export type OptionalType<Literal = unknown> = {
9
- type: DetailedType<Literal>;
10
- value: Literal;
7
+ export type RequiredType = RequiredUnion | RequiredSingle;
8
+ export type OptionalType = {
9
+ type: DetailedType;
10
+ value: unknown;
11
11
  optionalTypes?: DetailedType[];
12
12
  };
13
- export type PropertiesTypes<Literal = unknown> = OptionalType<Literal> | RequiredType<Literal>;
14
- export type PropertiesConstraint<Literal = unknown> = Record<string, PropertiesTypes<Literal>>;
13
+ export type PropertiesTypes = OptionalType | RequiredType;
14
+ export type PropertiesConstraint = Record<string, PropertiesTypes>;
@@ -53,4 +53,12 @@ RootComponent()({
53
53
  },
54
54
  },
55
55
  });
56
+ RootComponent()({
57
+ properties: {
58
+ obj: {
59
+ type: Object,
60
+ value: { gender: "male" },
61
+ },
62
+ },
63
+ });
56
64
  //# sourceMappingURL=normalOptional.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalOptional.test.js","sourceRoot":"","sources":["../../../../../src/api/RootComponent/Properties/test/normalOptional.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAMtC,MAAM,WAAW,GAAG,aAAa,EAAE,CAAC;IAClC,UAAU,EAAE;QACV,YAAY,EAAE;YACZ,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,GAAG;SACX;QACD,eAAe,EAAE;YACf,IAAI,EAAE,MAAyC;YAC/C,KAAK,EAAE,MAAM;SACd;QACD,cAAc,EAAE;YACd,IAAI,EAAE,KAA2D;YACjE,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAA8B;SACnD;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,MAAiC;YACvC,KAAK,EAAE;gBACL,EAAE,EAAE,IAAI;gBACR,GAAG,EAAE,EAAE;aACR;SACF;QACD,kBAAkB,EAAE;YAClB,IAAI,EAAE,MAAwC;YAC9C,KAAK,EAAE,IAAI;SACZ;QACD,cAAc,EAAE;YACd,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,QAAQ;YACf,aAAa,EAAE,CAAC,MAAM,CAAC;SACxB;KACF;IACD,OAAO,EAAE;QACP,GAAG;YAED,QAWC,CAAC;QACJ,CAAC;KACF;CACF,CAAC,CAAC;AAiBH,QAA4D,CAAC;AAO7D,aAAa,EAAE,CAAC;IACd,UAAU,EAAE;QACV,GAAG,EAAE,MAAmC;QACxC,IAAI,EAAE;YACJ,IAAI,EAAE,MAA2B;YACjC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;SACxB;KACF;IACD,QAAQ,EAAE;QACR,GAAG;;YACD,MAAA,IAAI,CAAC,IAAI,CAAC,IAAI,0CAAE,IAAI,CAAC;QACvB,CAAC;KACF;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"normalOptional.test.js","sourceRoot":"","sources":["../../../../../src/api/RootComponent/Properties/test/normalOptional.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAGhD,OAAO,EAAE,aAAa,EAA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
31
31
  import type { WatchOption } from "./Watch/WatchOption";
32
32
  type RootComponentOptions<TReceivedComponentDoc extends object, TEvents extends object, TIsPage extends boolean, TCustomEvents extends CustomEventConstraint, TMethods extends MethodsConstraint, TProperties extends PropertiesConstraint, TData extends object, TStore extends StoreConstraint, TComputed extends Record<string, Func>, EventsDoc extends object, CustomEventsDoc extends object, PropertiesDoc extends object, DataDoc extends object, StoreDoc extends object, ComputedDoc extends object> = MethodsOption<TMethods, keyof (EventsDoc & CustomEventsDoc)> & PropertiesOption<TProperties> & IsPageOption<TIsPage> & CustomEventsOption<TCustomEvents, EventsDoc> & EventsOption<TEvents, EventsConstraint<TReceivedComponentDoc>> & DataOption<TData, PropertiesDoc> & StoreOption<TStore, PropertiesDoc & DataDoc> & ComputedOption<TComputed, Required<PropertiesDoc> & DataDoc & StoreDoc> & PageLifetimesOption<TIsPage, NoInfer<PropertiesDoc>> & LifetimesOption<TIsPage> & WatchOption<ComputedDoc & Required<PropertiesDoc> & DataDoc & StoreDoc> & Partial<Omit<WMCompOtherOption, "pageLifetimes">> & ThisType<RootComponentInstance<TIsPage, TMethods, DataDoc, DataDoc & Required<PropertiesDoc> & StoreDoc & ComputedDoc, CustomEventsDoc, StoreDoc>>;
33
33
  type RootComponentConstructor<TReceivedComponentDoc extends ComponentDoc[] | ComponentDoc> = {
34
- <Literal extends string | number | boolean | null | Literal[] | object, TEvents extends EventsConstraint<TReceivedComponentDoc>, TIsPage extends boolean = false, TProperties extends PropertiesConstraint<Literal> = {}, TData extends object = {}, TStore extends StoreConstraint = {}, TComputed extends ComputedConstraint = {}, TCustomEvents extends IfExtends<TIsPage, false, CustomEventConstraint, EmptyObject> = {}, TMethods extends MethodsConstraint = {}, EventsDoc extends object = IfExtends<EventsConstraint<TReceivedComponentDoc>, TEvents, {}, TEvents>, CustomEventsDoc extends object = GetCustomEventDoc<TCustomEvents>, PropertiesDoc extends object = GetPropertiesDoc<TProperties, TIsPage>, DataDoc extends object = TData, StoreDoc extends object = GeTStoreDoc<TStore>, ComputedDoc extends object = GetComputedDoc<TComputed>>(options: RootComponentOptions<TReceivedComponentDoc, TEvents, TIsPage, TCustomEvents, TMethods, TProperties, TData, TStore, TComputed, EventsDoc, CustomEventsDoc, PropertiesDoc, DataDoc, StoreDoc, ComputedDoc>): ComputeIntersectionDeep<IfExtends<TIsPage, false, {}, {
34
+ <TEvents extends EventsConstraint<TReceivedComponentDoc>, TIsPage extends boolean = false, const TProperties extends PropertiesConstraint = {}, TData extends object = {}, TStore extends StoreConstraint = {}, TComputed extends ComputedConstraint = {}, TCustomEvents extends IfExtends<TIsPage, false, CustomEventConstraint, EmptyObject> = {}, TMethods extends MethodsConstraint = {}, EventsDoc extends object = IfExtends<EventsConstraint<TReceivedComponentDoc>, TEvents, {}, TEvents>, CustomEventsDoc extends object = GetCustomEventDoc<TCustomEvents>, PropertiesDoc extends object = GetPropertiesDoc<TProperties, TIsPage>, DataDoc extends object = TData, StoreDoc extends object = GeTStoreDoc<TStore>, ComputedDoc extends object = GetComputedDoc<TComputed>>(options: RootComponentOptions<TReceivedComponentDoc, TEvents, TIsPage, TCustomEvents, TMethods, TProperties, TData, TStore, TComputed, EventsDoc, CustomEventsDoc, PropertiesDoc, DataDoc, StoreDoc, ComputedDoc>): ComputeIntersectionDeep<IfExtends<TIsPage, false, {}, {
35
35
  isPage: true;
36
36
  }> & IfExtends<EmptyObject, PropertiesDoc, {}, {
37
37
  properties: PropertiesDoc;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/RootComponent/index.ts"],"names":[],"mappings":"AAqIA,MAAM,UAAU,aAAa;IAM3B,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAmC,CAAQ,CAAC;AACxE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/RootComponent/index.ts"],"names":[],"mappings":"AA8HA,MAAM,UAAU,aAAa;IAM3B,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAmC,CAAQ,CAAC;AACxE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "annil",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "微信小程序(原生开发)插件",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -47,7 +47,7 @@
47
47
  "author": "missannil",
48
48
  "license": "MIT",
49
49
  "dependencies": {
50
- "hry-types": "^0.16.12",
50
+ "hry-types": "^0.17.0",
51
51
  "miniprogram-api-typings": "^3.12.1"
52
52
  }
53
53
  }
@@ -1,7 +1,7 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
2
  import type { Select } from "hry-types/src/Object/Select";
3
3
 
4
- import type { ComputeIntersection } from "hry-types/src/Object/_api";
4
+ import type { ComputeIntersection, NonReadonlyDeep } from "hry-types/src/Object/_api";
5
5
  import type { GetOptionalDoc } from "./GetOptionalDoc";
6
6
  import type { GetRequiredDoc } from "./GetRequiredDoc";
7
7
  import type { OptionalType, PropertiesConstraint } from "./PropertiesConstraint";
@@ -10,8 +10,8 @@ type _GetPropertiesDoc<
10
10
  TProperties extends PropertiesConstraint,
11
11
  TIsPage extends boolean,
12
12
  Type extends "Required" | "Optional" | "all" = "all",
13
- OptionalDoc = GetOptionalDoc<Select<TProperties, OptionalType>, TIsPage>,
14
- RequiredDoc = GetRequiredDoc<Omit<TProperties, keyof OptionalDoc>, TIsPage>,
13
+ OptionalDoc = NonReadonlyDeep<GetOptionalDoc<Select<TProperties, OptionalType>, TIsPage>>,
14
+ RequiredDoc = NonReadonlyDeep<GetRequiredDoc<Omit<TProperties, keyof OptionalDoc>, TIsPage>>,
15
15
  > = IfExtends<
16
16
  Type,
17
17
  "all",
@@ -8,31 +8,31 @@ export type RequiredSingle = DetailedType;
8
8
  /**
9
9
  * properties 必传(联合)类型
10
10
  */
11
- export type RequiredUnion<Literal = unknown> = {
12
- type: DetailedType<Literal>;
11
+ export type RequiredUnion = {
12
+ type: DetailedType;
13
13
  optionalTypes: DetailedType[];
14
14
  };
15
15
 
16
16
  /**
17
17
  * properties 必传类型
18
18
  */
19
- export type RequiredType<Literal = unknown> = RequiredUnion<Literal> | RequiredSingle;
19
+ export type RequiredType = RequiredUnion | RequiredSingle;
20
20
 
21
21
  /**
22
22
  * properties 选传类型
23
23
  */
24
- export type OptionalType<Literal = unknown> = {
25
- type: DetailedType<Literal>;
26
- value: Literal;
24
+ export type OptionalType = {
25
+ type: DetailedType;
26
+ value: unknown;
27
27
  optionalTypes?: DetailedType[];
28
28
  };
29
29
 
30
30
  /**
31
31
  * Properties 字段类型
32
32
  */
33
- export type PropertiesTypes<Literal = unknown> = OptionalType<Literal> | RequiredType<Literal>;
33
+ export type PropertiesTypes = OptionalType | RequiredType;
34
34
 
35
35
  /**
36
36
  * RootComponent API properties 字段约束
37
37
  */
38
- export type PropertiesConstraint<Literal = unknown> = Record<string, PropertiesTypes<Literal>>;
38
+ export type PropertiesConstraint = Record<string, PropertiesTypes>;
@@ -93,3 +93,17 @@ RootComponent()({
93
93
  },
94
94
  },
95
95
  });
96
+
97
+ /**
98
+ * 对象类型字面量类型可验证通过。
99
+ */
100
+ type obj = { gender: "male" | "femal" };
101
+
102
+ RootComponent()({
103
+ properties: {
104
+ obj: {
105
+ type: Object as DetailedType<obj>,
106
+ value: { gender: "male" },
107
+ },
108
+ },
109
+ });
@@ -77,17 +77,10 @@ type RootComponentOptions<
77
77
 
78
78
  type RootComponentConstructor<TReceivedComponentDoc extends ComponentDoc[] | ComponentDoc> = {
79
79
  <
80
- Literal extends
81
- | string
82
- | number
83
- | boolean
84
- | null
85
- | Literal[]
86
- | object,
87
80
  // TEvents 不能有默认值 {} 会引起事件参数类型(e)失效
88
81
  TEvents extends EventsConstraint<TReceivedComponentDoc>,
89
82
  TIsPage extends boolean = false,
90
- TProperties extends PropertiesConstraint<Literal> = {},
83
+ const TProperties extends PropertiesConstraint = {},
91
84
  TData extends object = {},
92
85
  TStore extends StoreConstraint = {},
93
86
  TComputed extends ComputedConstraint = {},