annil 1.0.6 → 1.0.8

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/api/DefineComponent/ReturnType/CreateComponentDoc.d.ts +2 -2
  3. package/dist/api/DefineComponent/ReturnType/CreatePageDoc.d.ts +4 -7
  4. package/dist/api/DefineComponent/ReturnType/test/normalPageDoc.test.js +6 -0
  5. package/dist/api/DefineComponent/ReturnType/test/normalPageDoc.test.js.map +1 -1
  6. package/dist/api/DefineComponent/index.d.ts +1 -1
  7. package/dist/api/RootComponent/Properties/GetOptionalDoc.d.ts +3 -4
  8. package/dist/api/RootComponent/Properties/GetPropertiesDoc.d.ts +3 -4
  9. package/dist/api/RootComponent/Properties/GetRequiredDoc.d.ts +3 -4
  10. package/dist/api/RootComponent/Store/test/normal.test.js +3 -1
  11. package/dist/api/RootComponent/Store/test/normal.test.js.map +1 -1
  12. package/dist/api/RootComponent/index.d.ts +5 -4
  13. package/dist/api/RootComponent/index.js.map +1 -1
  14. package/dist/api/SubComponent/SubData/test/normal.test.js.map +1 -1
  15. package/dist/api/SubComponent/index.d.ts +2 -2
  16. package/dist/index.d.ts +4 -3
  17. package/dist/index.js.map +1 -1
  18. package/dist/types/ComponentDocExtension.d.ts +7 -0
  19. package/dist/types/ComponentDocExtension.js +2 -0
  20. package/dist/types/ComponentDocExtension.js.map +1 -0
  21. package/dist/types/ComputeObj.d.ts +3 -0
  22. package/dist/types/ComputeObj.js +2 -0
  23. package/dist/types/ComputeObj.js.map +1 -0
  24. package/dist/types/GetComponentPrefix.d.ts +2 -1
  25. package/package.json +1 -1
  26. package/src/api/DefineComponent/ReturnType/CreateComponentDoc.ts +2 -2
  27. package/src/api/DefineComponent/ReturnType/CreatePageDoc.ts +4 -12
  28. package/src/api/DefineComponent/ReturnType/test/normalPageDoc.test.ts +9 -0
  29. package/src/api/DefineComponent/index.ts +1 -1
  30. package/src/api/RootComponent/CustomEvents/GetCustomEventDoc.ts +0 -2
  31. package/src/api/RootComponent/Properties/GetOptionalDoc.ts +10 -11
  32. package/src/api/RootComponent/Properties/GetPropertiesDoc.ts +6 -16
  33. package/src/api/RootComponent/Properties/GetRequiredDoc.ts +25 -15
  34. package/src/api/RootComponent/Store/test/normal.test.ts +11 -1
  35. package/src/api/RootComponent/index.ts +6 -5
  36. package/src/api/SubComponent/SubData/test/normal.test.ts +5 -2
  37. package/src/api/SubComponent/index.ts +2 -2
  38. package/src/index.ts +5 -4
  39. package/src/types/ComponentDocExtension.ts +36 -0
  40. package/src/types/ComputeObj.ts +1 -0
  41. package/src/types/GetComponentPrefix.ts +15 -13
  42. package/dist/types/CompDocExtends.d.ts +0 -8
  43. package/dist/types/CompDocExtends.js +0 -2
  44. package/dist/types/CompDocExtends.js.map +0 -1
  45. package/dist/types/Drop.d.ts +0 -2
  46. package/dist/types/Drop.js +0 -2
  47. package/dist/types/Drop.js.map +0 -1
  48. package/dist/types/DropStr.d.ts +0 -1
  49. package/dist/types/DropStr.js +0 -2
  50. package/dist/types/DropStr.js.map +0 -1
  51. package/dist/types/RestorePropertiesDoc.d.ts +0 -0
  52. package/dist/types/RestorePropertiesDoc.js +0 -2
  53. package/dist/types/RestorePropertiesDoc.js.map +0 -1
  54. package/src/types/CompDocExtends.ts +0 -14
  55. package/src/types/Drop.ts +0 -18
  56. package/src/types/DropStr.ts +0 -5
  57. package/src/types/RestorePropertiesDoc.ts +0 -26
package/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@
4
4
 
5
5
  * 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
6
6
 
7
+ ## [1.0.8](https://github.com/missannil/annil/compare/v1.0.7...v1.0.8) (2023-12-03)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * 组件类型中别名被解析的问题 ([67e4886](https://github.com/missannil/annil/commit/67e48868b55853c41f5ad4c713dab12e31380f64))
13
+
14
+ ## [1.0.7](https://github.com/missannil/annil/compare/v1.0.6...v1.0.7) (2023-12-02)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * 修复DefinedComponent的subComonsnts字段为[never]类型时,生成page类型错误的情况 ([a8aec74](https://github.com/missannil/annil/commit/a8aec74bbe964585f71d96bebdc85a32241271aa))
20
+
7
21
  ## [1.0.6](https://github.com/missannil/annil/compare/v1.0.5...v1.0.6) (2023-12-02)
8
22
 
9
23
 
@@ -1,5 +1,5 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
- import type { ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
2
+ import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
3
3
  import type { AddNullForObject } from "../../../types/AddNullForObject";
4
4
  import type { RootComponentDoc } from "../../RootComponent/RootComponentDoc";
5
5
  import type { SubComponentDoc } from "../../SubComponent/SubComponentDoc";
@@ -7,7 +7,7 @@ import type { GetCustomEventDocOfSubDoc } from "./GetCustomEventDocOfSubDoc";
7
7
  type GetStopKeys<O> = {
8
8
  [k in keyof O]: k extends `${string}_${infer Key}_${string}_catch` ? Key : never;
9
9
  }[keyof O];
10
- export type CreateComponentDoc<TRootDoc extends RootComponentDoc, TName extends string, TSubComponentTuple extends SubComponentDoc[], AllPropertiesDoc extends unknown | object = TRootDoc["properties"], AllCustomEventsDoc extends unknown | object = TRootDoc["customEvents"] & GetCustomEventDocOfSubDoc<TSubComponentTuple[number]>, StopKeys extends string = GetStopKeys<TRootDoc["events"]>, FinalCustomEventDoc extends object = Omit<AllCustomEventsDoc, StopKeys>> = ComputeIntersectionDeep<IfExtends<unknown, AllPropertiesDoc, {}, {
10
+ export type CreateComponentDoc<TRootDoc extends RootComponentDoc, TName extends string, TSubComponentTuple extends SubComponentDoc[], AllPropertiesDoc extends unknown | object = TRootDoc["properties"], AllCustomEventsDoc extends unknown | object = TRootDoc["customEvents"] & GetCustomEventDocOfSubDoc<TSubComponentTuple[number]>, StopKeys extends string = GetStopKeys<TRootDoc["events"]>, FinalCustomEventDoc extends object = Omit<AllCustomEventsDoc, StopKeys>> = ComputeIntersection<IfExtends<unknown, AllPropertiesDoc, {}, {
11
11
  properties: {
12
12
  [k in keyof AllPropertiesDoc as `${TName}_${k & string}`]: AddNullForObject<AllPropertiesDoc[k]>;
13
13
  };
@@ -1,11 +1,8 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
- import type { ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
3
- import type { RemoveNullOfRequired } from "../../../types/RemoveNullOfRequired";
2
+ import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
4
3
  import type { RootComponentDoc } from "../../RootComponent/RootComponentDoc";
5
- import type { SubComponentDoc } from "../../SubComponent/SubComponentDoc";
6
- import type { GetPropertiesDocOfSubDoc } from "./GetPropertiesDocOfSubDoc";
7
- export type CreatePageDoc<TRootDoc extends RootComponentDoc, TPath extends string, TSubComponentTuple extends SubComponentDoc[], AllPropertiesDoc = TRootDoc["properties"] & GetPropertiesDocOfSubDoc<TSubComponentTuple>> = ComputeIntersectionDeep<{
4
+ export type CreatePageDoc<TRootDoc extends RootComponentDoc, TPath extends string> = ComputeIntersection<{
8
5
  path: TPath;
9
- } & IfExtends<unknown, AllPropertiesDoc, unknown, {
10
- properties: RemoveNullOfRequired<AllPropertiesDoc>;
6
+ } & IfExtends<unknown, TRootDoc["properties"], unknown, {
7
+ properties: TRootDoc["properties"];
11
8
  }>>;
@@ -22,4 +22,10 @@ const compDocOnlyProperties = DefineComponent({
22
22
  rootComponent: OnlyPropsRootDoc,
23
23
  });
24
24
  Checking;
25
+ const whenSubIsAllNever = DefineComponent({
26
+ path: "/pages/index/index",
27
+ rootComponent: OnlyPropsRootDoc,
28
+ subComponents: [{}],
29
+ });
30
+ Checking;
25
31
  //# sourceMappingURL=normalPageDoc.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalPageDoc.test.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/ReturnType/test/normalPageDoc.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAChD,OAAO,EAAqB,aAAa,EAAE,MAAM,aAAa,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAExC,MAAM,gBAAgB,GAAG,aAAa,EAAE,CAAC;IACvC,MAAM,EAAE,IAAI;IACZ,UAAU,EAAE;QACV,GAAG,EAAE,MAAM;QACX,GAAG,EAAE,MAAiC;QACtC,WAAW,EAAE;YACX,IAAI,EAAE,MAAiC;YACvC,KAAK,EAAE,EAAe;SACvB;QACD,iBAAiB,EAAE;YACjB,IAAI,EAAE,MAAwC;YAC9C,KAAK,EAAE,IAAI;SACZ;KACF;IACD,YAAY,EAAE,EAAE;CACjB,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,eAAe,CAAC;IAC5C,IAAI,EAAE,oBAAoB;IAC1B,aAAa,EAAE,gBAAgB;CAChC,CAAC,CAAC;AAaH,QAAgF,CAAC"}
1
+ {"version":3,"file":"normalPageDoc.test.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/ReturnType/test/normalPageDoc.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAChD,OAAO,EAAqB,aAAa,EAAE,MAAM,aAAa,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAExC,MAAM,gBAAgB,GAAG,aAAa,EAAE,CAAC;IACvC,MAAM,EAAE,IAAI;IACZ,UAAU,EAAE;QACV,GAAG,EAAE,MAAM;QACX,GAAG,EAAE,MAAiC;QACtC,WAAW,EAAE;YACX,IAAI,EAAE,MAAiC;YACvC,KAAK,EAAE,EAAe;SACvB;QACD,iBAAiB,EAAE;YACjB,IAAI,EAAE,MAAwC;YAC9C,KAAK,EAAE,IAAI;SACZ;KACF;IACD,YAAY,EAAE,EAAE;CACjB,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,eAAe,CAAC;IAC5C,IAAI,EAAE,oBAAoB;IAC1B,aAAa,EAAE,gBAAgB;CAChC,CAAC,CAAC;AAaH,QAAgF,CAAC;AAGjF,MAAM,iBAAiB,GAAG,eAAe,CAAC;IACxC,IAAI,EAAE,oBAAoB;IAC1B,aAAa,EAAE,gBAAgB;IAC/B,aAAa,EAAE,CAAC,EAAW,CAAC;CAC7B,CAAC,CAAC;AAEH,QAA4E,CAAC"}
@@ -12,7 +12,7 @@ import type { SubComponentsOption } from "./SubComponents/SubComponentsOption";
12
12
  type Path = `/${string}`;
13
13
  type RootOptions<TRootComponentDoc extends RootComponentDoc, TSubComponentTuple extends SubComponentDoc[], TName extends string, TPath extends Path> = NameOrPathOption<TName, TPath, TRootComponentDoc> & RootComponentOption<TRootComponentDoc> & SubComponentsOption<TSubComponentTuple>;
14
14
  interface DefineComponentConstructor {
15
- <TRootComponentDoc extends RootComponentDoc = {}, TSubComponentTuple extends SubComponentDoc[] = [], TName extends string = "", TPath extends Path = "/">(options: RootOptions<TRootComponentDoc, TSubComponentTuple, TName, TPath>): IfExtends<"", TName, CreatePageDoc<TRootComponentDoc, TPath, TSubComponentTuple>, CreateComponentDoc<TRootComponentDoc, TName, TSubComponentTuple>>;
15
+ <TRootComponentDoc extends RootComponentDoc = {}, TSubComponentTuple extends SubComponentDoc[] = [], TName extends string = "", TPath extends Path = "/">(options: RootOptions<TRootComponentDoc, TSubComponentTuple, TName, TPath>): IfExtends<"", TName, CreatePageDoc<TRootComponentDoc, TPath>, CreateComponentDoc<TRootComponentDoc, TName, TSubComponentTuple>>;
16
16
  }
17
17
  export type FuncOptions = Record<"pageLifetimes" | "lifetimes" | "watch", Record<string, Func[]>>;
18
18
  export type FinalOptionsForComponent = {
@@ -1,8 +1,7 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
- import type { Select } from "hry-types/src/Object/Select";
3
2
  import type { AddNullForObject } from "../../../types/AddNullForObject";
4
3
  import type { InferDetailedType } from "../../../types/InferDetailedType";
5
- import type { OptionalType, PropertiesConstraint } from "./PropertiesConstraint";
6
- export type GetOptionalDoc<TProperties extends PropertiesConstraint, TIsPage extends boolean, Optional extends Record<string, OptionalType> = Select<TProperties, OptionalType>> = {
7
- [k in keyof Optional]?: IfExtends<unknown, Optional[k]["optionalTypes"], IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<Optional[k]["type"]>>, InferDetailedType<Optional[k]["type"]>>, IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<Optional[k]["type"]> | InferDetailedType<(Optional[k]["optionalTypes"] & {})[number]>>, InferDetailedType<Optional[k]["type"]> | InferDetailedType<(Optional[k]["optionalTypes"] & {})[number]>>>;
4
+ import type { OptionalType } from "./PropertiesConstraint";
5
+ export type GetOptionalDoc<TOptionalProperties extends Record<string, OptionalType>, TIsPage extends boolean> = {
6
+ -readonly [k in keyof TOptionalProperties]?: IfExtends<unknown, TOptionalProperties[k]["optionalTypes"], IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<TOptionalProperties[k]["type"]>>, InferDetailedType<TOptionalProperties[k]["type"]>>, IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<TOptionalProperties[k]["type"]> | InferDetailedType<(TOptionalProperties[k]["optionalTypes"] & {})[number]>>, InferDetailedType<TOptionalProperties[k]["type"]> | InferDetailedType<(TOptionalProperties[k]["optionalTypes"] & {})[number]>>>;
8
7
  };
@@ -1,9 +1,8 @@
1
- import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
1
  import type { Select } from "hry-types/src/Object/Select";
3
- import type { ComputeIntersection, NonReadonlyDeep } from "hry-types/src/Object/_api";
2
+ import type { ComputeIntersection } from "hry-types/src/Object/_api";
4
3
  import type { GetOptionalDoc } from "./GetOptionalDoc";
5
4
  import type { GetRequiredDoc } from "./GetRequiredDoc";
6
5
  import type { OptionalType, PropertiesConstraint } from "./PropertiesConstraint";
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
- export type GetPropertiesDoc<TProperties extends PropertiesConstraint, TisPage extends boolean, Type extends "Required" | "Optional" | "all" = "all"> = _GetPropertiesDoc<TProperties, TisPage, Type>;
6
+ type _GetPropertiesDoc<TProperties extends PropertiesConstraint, TIsPage extends boolean, OptionalDoc extends object = GetOptionalDoc<Select<TProperties, OptionalType>, TIsPage>, RequiredDoc extends object = GetRequiredDoc<Omit<TProperties, keyof OptionalDoc>, TIsPage>> = ComputeIntersection<OptionalDoc & RequiredDoc>;
7
+ export type GetPropertiesDoc<TProperties extends PropertiesConstraint, TisPage extends boolean> = _GetPropertiesDoc<TProperties, TisPage>;
9
8
  export {};
@@ -1,8 +1,7 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
- import type { Select } from "hry-types/src/Object/Select";
3
2
  import type { AddNullForObject } from "../../../types/AddNullForObject";
4
3
  import type { InferDetailedType } from "../../../types/InferDetailedType";
5
- import type { PropertiesConstraint, RequiredSingle, RequiredType } from "./PropertiesConstraint";
6
- export type GetRequiredDoc<TProperties extends PropertiesConstraint, TIsPage extends boolean, Required extends Record<string, RequiredType> = Select<TProperties, RequiredType>> = {
7
- [k in keyof Required]: IfExtends<Required[k], RequiredSingle, IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<Required[k]>>, InferDetailedType<Required[k]>>, IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<Required[k]["type"]>> | AddNullForObject<InferDetailedType<Required[k]["optionalTypes"][number]>>, InferDetailedType<Required[k]["type"]> | InferDetailedType<Required[k]["optionalTypes"][number]>>>;
4
+ import type { RequiredSingle, RequiredType } from "./PropertiesConstraint";
5
+ export type GetRequiredDoc<TProperties extends Record<string, RequiredType>, TIsPage extends boolean> = {
6
+ -readonly [k in keyof TProperties]: IfExtends<TProperties[k], RequiredSingle, IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<TProperties[k]>>, InferDetailedType<TProperties[k]>>, IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<TProperties[k]["type"]> | InferDetailedType<TProperties[k]["optionalTypes"][number]>>, InferDetailedType<TProperties[k]["type"]> | InferDetailedType<TProperties[k]["optionalTypes"][number]>>>;
8
7
  };
@@ -1,13 +1,15 @@
1
+ import { Checking } from "hry-types";
1
2
  import { observable } from "mobx";
2
3
  import { RootComponent } from "../..";
3
4
  const user = observable({
4
5
  name: "zhao",
5
6
  age: 20,
6
7
  });
7
- RootComponent()({
8
+ const storeDoc = RootComponent()({
8
9
  store: {
9
10
  userName: () => user.name,
10
11
  userAge: () => user.age,
11
12
  },
12
13
  });
14
+ Checking;
13
15
  //# sourceMappingURL=normal.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"normal.test.js","sourceRoot":"","sources":["../../../../../src/api/RootComponent/Store/test/normal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,MAAM,IAAI,GAAG,UAAU,CAAC;IACtB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,EAAE;CACR,CAAC,CAAC;AAEH,aAAa,EAAE,CAAC;IACd,KAAK,EAAE;QACL,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI;QACzB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG;KACxB;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"normal.test.js","sourceRoot":"","sources":["../../../../../src/api/RootComponent/Store/test/normal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,MAAM,IAAI,GAAG,UAAU,CAAC;IACtB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,EAAE;CACR,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,aAAa,EAAE,CAAC;IAC/B,KAAK,EAAE;QACL,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI;QACzB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG;KACxB;CACF,CAAC,CAAC;AASH,QAAsD,CAAC"}
@@ -2,7 +2,8 @@ import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
2
  import type { NoInfer } from "hry-types/src/Generic/NoInfer";
3
3
  import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
4
4
  import type { Func } from "hry-types/src/Misc/Func";
5
- import type { ComputeIntersectionDeep } from "hry-types/src/Object/_api";
5
+ import type { ComputeIntersection } from "hry-types/src/Object/_api";
6
+ import type { ComputeObject } from "../../types/ComputeObj";
6
7
  import type { WMCompOtherOption, WMCompPageLifetimes, WMPageLifetimes } from "../../types/OfficialTypeAlias";
7
8
  import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
8
9
  import type { ComputedConstraint } from "./Computed/ComputedConstraint";
@@ -31,14 +32,14 @@ import type { StoreOption } from "./Store/StoreOption";
31
32
  import type { WatchOption } from "./Watch/WatchOption";
32
33
  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
34
  type RootComponentConstructor<TReceivedComponentDoc extends ComponentDoc[] | ComponentDoc> = {
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
+ <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>): ComputeIntersection<IfExtends<TIsPage, false, {}, {
35
36
  isPage: true;
36
37
  }> & IfExtends<EmptyObject, PropertiesDoc, {}, {
37
38
  properties: PropertiesDoc;
38
39
  }> & IfExtends<EmptyObject, DataDoc, {}, {
39
40
  data: DataDoc;
40
41
  }> & IfExtends<EmptyObject, StoreDoc, {}, {
41
- store: StoreDoc;
42
+ store: ComputeObject<StoreDoc>;
42
43
  }> & IfExtends<EmptyObject, ComputedDoc, {}, {
43
44
  computed: ComputedDoc;
44
45
  }> & IfExtends<EmptyObject, TMethods, {}, {
@@ -46,7 +47,7 @@ type RootComponentConstructor<TReceivedComponentDoc extends ComponentDoc[] | Com
46
47
  }> & IfExtends<EmptyObject, EventsDoc, {}, {
47
48
  events: EventsDoc;
48
49
  }> & IfExtends<EmptyObject, CustomEventsDoc, {}, {
49
- customEvents: CustomEventsDoc;
50
+ customEvents: ComputeObject<CustomEventsDoc>;
50
51
  }>>;
51
52
  };
52
53
  export declare function RootComponent<TReceivedComponentDoc extends ComponentDoc[] | ComponentDoc = {}>(): RootComponentConstructor<TReceivedComponentDoc>;
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/RootComponent/index.ts"],"names":[],"mappings":"AA+HA,MAAM,UAAU,aAAa;IAM3B,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAmC,CAAQ,CAAC;AACxE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"normal.test.js","sourceRoot":"","sources":["../../../../../src/api/SubComponent/SubData/test/normal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAOhD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAWrC,YAAY,EAAe,CAAC;IAC1B,OAAO,EAAE;QACP,OAAO,EAAE,MAAM;KAChB;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,GAAG;QACZ,aAAa,EAAE,UAAU;KAC1B;CACF,CAAC,CAAC;AAKH,MAAM,GAAG,GAAG,YAAY,EAAmB,CAAC;IAC1C,OAAO,EAAE;QACP,UAAU,EAAE,MAAM;KACnB;IACD,IAAI,EAAE;QAEJ,UAAU,EAAE,QAAQ;QACpB,gBAAgB,EAAE,MAAM;QAExB,QAAQ,EAAE,EAAsB;QAChC,QAAQ,EAAE,GAAG;QACb,QAAQ,EAAE,GAAG;KACd;CACF,CAAC,CAAC;AAEH,QAAsC,CAAC;AAGvC,YAAY,EAAe,CAAC;IAC1B,OAAO,EAAE;QACP,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,MAAM;KAChB;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC,CAAC;AAMH,MAAM,IAAI,GAAG,YAAY,EAAoB,CAAC,EAAE,CAAC,CAAC;AAElD,QAAuC,CAAC;AAExC,YAAY,EAAe,CAAC;IAC1B,IAAI,EAAE;QACJ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK;KAChB;IACD,OAAO,EAAE;QACP,KAAK;YAEH,QASC,CAAC;QACJ,CAAC;KACF;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"normal.test.js","sourceRoot":"","sources":["../../../../../src/api/SubComponent/SubData/test/normal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAOhD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAWrC,YAAY,EAAe,CAAC;IAC1B,OAAO,EAAE;QACP,OAAO,EAAE,MAAM;KAChB;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,GAAG;QACZ,aAAa,EAAE,UAAU;KAC1B;CACF,CAAC,CAAC;AAQH,MAAM,GAAG,GAAG,YAAY,EAAmB,CAAC;IAC1C,OAAO,EAAE;QACP,UAAU,EAAE,MAAM;KACnB;IACD,IAAI,EAAE;QAEJ,UAAU,EAAE,QAAQ;QACpB,gBAAgB,EAAE,MAAM;QAExB,QAAQ,EAAE,EAAsB;QAChC,QAAQ,EAAE,GAAG;QACb,QAAQ,EAAE,GAAG;KACd;CACF,CAAC,CAAC;AAEH,QAAsC,CAAC;AAGvC,YAAY,EAAe,CAAC;IAC1B,OAAO,EAAE;QACP,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,MAAM;KAChB;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC,CAAC;AAMH,MAAM,IAAI,GAAG,YAAY,EAAoB,CAAC,EAAE,CAAC,CAAC;AAElD,QAAuC,CAAC;AAExC,YAAY,EAAe,CAAC;IAC1B,IAAI,EAAE;QACJ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK;KAChB;IACD,OAAO,EAAE;QACP,KAAK;YAEH,QASC,CAAC;QACJ,CAAC;KACF;CACF,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
2
  import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
3
3
  import type { RequiredKeys } from "hry-types/src/Object/RequiredKeys";
4
- import type { ExtractDocPrefix } from "../../types/GetComponentPrefix";
4
+ 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";
@@ -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"] & TRootDoc["store"]> = {
30
+ 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"]> = {
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>;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- export type { Vant, Wm } from "./thirdLib";
2
- export type { Dataset, Detail, WMBaseEvent, WMCustomEvent } from "./types/OfficialTypeAlias";
3
1
  import { navigateTo } from "./api/navigateTo";
4
2
  import { DefineComponent } from "./api/DefineComponent";
5
3
  import { RootComponent } from "./api/RootComponent";
6
4
  import { SubComponent } from "./api/SubComponent";
7
5
  import type { DetailedType } from "./types/DetailedType";
6
+ import type { ComponentDocExtension } from "./types/ComponentDocExtension";
8
7
  import type { GenerateDoc } from "./types/GenerateDoc";
9
8
  import type { ParamsEqual } from "./types/TwoParamsEqual";
10
- export { DefineComponent, type DetailedType, type GenerateDoc, navigateTo, type ParamsEqual, RootComponent, SubComponent, };
9
+ export type { Vant, Wm } from "./thirdLib";
10
+ export type { Dataset, Detail, WMBaseEvent, WMCustomEvent } from "./types/OfficialTypeAlias";
11
+ export { type ComponentDocExtension, DefineComponent, type DetailedType, type GenerateDoc, navigateTo, type ParamsEqual, RootComponent, SubComponent, };
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;AAOlD,OAAO,EACL,eAAe,EAGf,UAAU,EAEV,aAAa,EACb,YAAY,GACb,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,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;AAWlD,OAAO,EAEL,eAAe,EAGf,UAAU,EAEV,aAAa,EACb,YAAY,GACb,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
+ import type { ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
3
+ import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
4
+ import type { GetComponentPrefix } from "./GetComponentPrefix";
5
+ type Validator<TOriginalComponentDoc extends ComponentDoc, TExtensionDoc extends ComponentDoc, TOriginalPrefix extends PropertyKey = GetComponentPrefix<TOriginalComponentDoc>, TExtenstionPrefix extends PropertyKey = GetComponentPrefix<TExtensionDoc>, DuplicateKeys extends PropertyKey = Extract<keyof TExtensionDoc["properties"], keyof TOriginalComponentDoc["properties"]> | Extract<keyof TExtensionDoc["customEvents"], keyof TOriginalComponentDoc["customEvents"]>> = IfExtends<TOriginalPrefix, TExtenstionPrefix, IfExtends<DuplicateKeys, never, ComponentDoc, `${DuplicateKeys & string}字段重复`>, `前缀错误,应为${TOriginalPrefix & string}`>;
6
+ export type ComponentDocExtension<TOriginalComponentDoc extends ComponentDoc, TExtensionDoc extends Validator<TOriginalComponentDoc, TExtensionDoc>> = ComputeIntersectionDeep<TOriginalComponentDoc & TExtensionDoc>;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ComponentDocExtension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentDocExtension.js","sourceRoot":"","sources":["../../src/types/ComponentDocExtension.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export type ComputeObject<T> = T extends unknown ? {
2
+ [k in keyof T]: T[k];
3
+ } : never;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ComputeObj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComputeObj.js","sourceRoot":"","sources":["../../src/types/ComputeObj.ts"],"names":[],"mappings":""}
@@ -1,3 +1,4 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
+ import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
2
3
  import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
3
- export type ExtractDocPrefix<TComponentDoc extends ComponentDoc> = keyof IfExtends<unknown, TComponentDoc["properties"], TComponentDoc["customEvents"], TComponentDoc["properties"]> extends `${infer P}_${string}` ? P : "";
4
+ export type GetComponentPrefix<TComponentDoc extends ComponentDoc> = EmptyObject extends TComponentDoc ? never : keyof IfExtends<unknown, TComponentDoc["properties"], TComponentDoc["customEvents"], TComponentDoc["properties"]> extends `${infer P}_${string}` ? P : never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "annil",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "微信小程序(原生开发)插件",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
- import type { ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
2
+ import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
3
3
  import type { AddNullForObject } from "../../../types/AddNullForObject";
4
4
  import type { RootComponentDoc } from "../../RootComponent/RootComponentDoc";
5
5
  import type { SubComponentDoc } from "../../SubComponent/SubComponentDoc";
@@ -19,7 +19,7 @@ export type CreateComponentDoc<
19
19
  & GetCustomEventDocOfSubDoc<TSubComponentTuple[number]>,
20
20
  StopKeys extends string = GetStopKeys<TRootDoc["events"]>,
21
21
  FinalCustomEventDoc extends object = Omit<AllCustomEventsDoc, StopKeys>,
22
- > = ComputeIntersectionDeep<
22
+ > = ComputeIntersection<
23
23
  & IfExtends<
24
24
  unknown,
25
25
  AllPropertiesDoc,
@@ -1,26 +1,18 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
- import type { ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
3
- import type { RemoveNullOfRequired } from "../../../types/RemoveNullOfRequired";
2
+ import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
4
3
  import type { RootComponentDoc } from "../../RootComponent/RootComponentDoc";
5
- import type { SubComponentDoc } from "../../SubComponent/SubComponentDoc";
6
- import type { GetPropertiesDocOfSubDoc } from "./GetPropertiesDocOfSubDoc";
7
4
 
8
5
  export type CreatePageDoc<
9
6
  TRootDoc extends RootComponentDoc,
10
7
  TPath extends string,
11
- TSubComponentTuple extends SubComponentDoc[],
12
- // 获取所有properties字段
13
- AllPropertiesDoc = TRootDoc["properties"] & GetPropertiesDocOfSubDoc<TSubComponentTuple>,
14
- > = ComputeIntersectionDeep<
8
+ > = ComputeIntersection<
15
9
  & { path: TPath }
16
10
  & IfExtends<
17
11
  unknown,
18
- AllPropertiesDoc,
12
+ TRootDoc["properties"],
19
13
  unknown,
20
14
  {
21
- // @ts-ignore AllPropertiesDoc 必为 object
22
- // RemoveNullOfRequired 页面传值时必传字段不需要RootComponent返回时为对象加入的null类型
23
- properties: RemoveNullOfRequired<AllPropertiesDoc>;
15
+ properties: TRootDoc["properties"];
24
16
  }
25
17
  >
26
18
  >;
@@ -38,3 +38,12 @@ type CompDocOnlyPropertiesExpected = {
38
38
  };
39
39
 
40
40
  Checking<typeof compDocOnlyProperties, CompDocOnlyPropertiesExpected, Test.Pass>;
41
+
42
+ // 页面类型不受subComponents是[never,never]时影响
43
+ const whenSubIsAllNever = DefineComponent({
44
+ path: "/pages/index/index",
45
+ rootComponent: OnlyPropsRootDoc,
46
+ subComponents: [{} as never],
47
+ });
48
+
49
+ Checking<typeof whenSubIsAllNever, CompDocOnlyPropertiesExpected, Test.Pass>;
@@ -39,7 +39,7 @@ interface DefineComponentConstructor {
39
39
  "",
40
40
  TName,
41
41
  // 生成页面文档
42
- CreatePageDoc<TRootComponentDoc, TPath, TSubComponentTuple>,
42
+ CreatePageDoc<TRootComponentDoc, TPath>,
43
43
  // 生成组件文档
44
44
  CreateComponentDoc<TRootComponentDoc, TName, TSubComponentTuple>
45
45
  >;
@@ -42,5 +42,3 @@ export type GetCustomEventDoc<T extends CustomEventConstraint> =
42
42
  | AddTagForCustomEventsDoc<T[k]["options"]>;
43
43
  }
44
44
  ;
45
-
46
- // type ddd = IsUnion
@@ -1,38 +1,37 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
- import type { Select } from "hry-types/src/Object/Select";
3
2
  import type { AddNullForObject } from "../../../types/AddNullForObject";
4
3
  import type { InferDetailedType } from "../../../types/InferDetailedType";
5
- import type { OptionalType, PropertiesConstraint } from "./PropertiesConstraint";
4
+ import type { OptionalType } from "./PropertiesConstraint";
6
5
 
7
6
  /**
8
7
  * 获取properties可传字段文档类型
9
8
  */
10
9
  export type GetOptionalDoc<
11
- TProperties extends PropertiesConstraint,
10
+ TOptionalProperties extends Record<string, OptionalType>,
12
11
  TIsPage extends boolean,
13
- // @ts-ignore
14
- Optional extends Record<string, OptionalType> = Select<TProperties, OptionalType>,
15
12
  > = {
16
- [k in keyof Optional]?: IfExtends<
13
+ -readonly [k in keyof TOptionalProperties]?: IfExtends<
17
14
  unknown,
18
- Optional[k]["optionalTypes"],
15
+ TOptionalProperties[k]["optionalTypes"],
19
16
  IfExtends<
20
17
  false,
21
18
  TIsPage,
22
19
  // 组件时 对象加null
23
- AddNullForObject<InferDetailedType<Optional[k]["type"]>>,
20
+ AddNullForObject<InferDetailedType<TOptionalProperties[k]["type"]>>,
24
21
  // 页面时 对象不加
25
- InferDetailedType<Optional[k]["type"]>
22
+ InferDetailedType<TOptionalProperties[k]["type"]>
26
23
  >,
27
24
  IfExtends<
28
25
  false,
29
26
  TIsPage,
30
27
  // 组件时 对象加null
31
28
  AddNullForObject<
32
- InferDetailedType<Optional[k]["type"]> | InferDetailedType<(Optional[k]["optionalTypes"] & {})[number]>
29
+ | InferDetailedType<TOptionalProperties[k]["type"]>
30
+ | InferDetailedType<(TOptionalProperties[k]["optionalTypes"] & {})[number]>
33
31
  >,
34
32
  // 页面时 对象不加
35
- InferDetailedType<Optional[k]["type"]> | InferDetailedType<(Optional[k]["optionalTypes"] & {})[number]>
33
+ | InferDetailedType<TOptionalProperties[k]["type"]>
34
+ | InferDetailedType<(TOptionalProperties[k]["optionalTypes"] & {})[number]>
36
35
  >
37
36
  >;
38
37
  };
@@ -1,7 +1,6 @@
1
- import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
1
  import type { Select } from "hry-types/src/Object/Select";
3
2
 
4
- import type { ComputeIntersection, NonReadonlyDeep } from "hry-types/src/Object/_api";
3
+ import type { ComputeIntersection } from "hry-types/src/Object/_api";
5
4
  import type { GetOptionalDoc } from "./GetOptionalDoc";
6
5
  import type { GetRequiredDoc } from "./GetRequiredDoc";
7
6
  import type { OptionalType, PropertiesConstraint } from "./PropertiesConstraint";
@@ -9,25 +8,16 @@ import type { OptionalType, PropertiesConstraint } from "./PropertiesConstraint"
9
8
  type _GetPropertiesDoc<
10
9
  TProperties extends PropertiesConstraint,
11
10
  TIsPage extends boolean,
12
- Type extends "Required" | "Optional" | "all" = "all",
13
- OptionalDoc = NonReadonlyDeep<GetOptionalDoc<Select<TProperties, OptionalType>, TIsPage>>,
14
- RequiredDoc = NonReadonlyDeep<GetRequiredDoc<Omit<TProperties, keyof OptionalDoc>, TIsPage>>,
15
- > = IfExtends<
16
- Type,
17
- "all",
18
11
  // @ts-ignore
19
- ComputeIntersection<OptionalDoc & RequiredDoc>,
20
- IfExtends<Type, "Optional", OptionalDoc, RequiredDoc>
21
- >;
12
+ OptionalDoc extends object = GetOptionalDoc<Select<TProperties, OptionalType>, TIsPage>,
13
+ // @ts-ignore
14
+ RequiredDoc extends object = GetRequiredDoc<Omit<TProperties, keyof OptionalDoc>, TIsPage>,
15
+ > = ComputeIntersection<OptionalDoc & RequiredDoc>;
22
16
 
23
17
  /**
24
18
  * properties字段的文档类型
25
- * @param TProperties - `PropertiesConstraint`
26
- * @param Type - "Required" | "Optional" | "all"
27
- * @returns `GetRequiredDoc` | `GetOptionalDoc` | (`GetOptionalDoc` & `GetRequiredDoc`)
28
19
  */
29
20
  export type GetPropertiesDoc<
30
21
  TProperties extends PropertiesConstraint,
31
22
  TisPage extends boolean,
32
- Type extends "Required" | "Optional" | "all" = "all",
33
- > = _GetPropertiesDoc<TProperties, TisPage, Type>;
23
+ > = _GetPropertiesDoc<TProperties, TisPage>;
@@ -1,32 +1,42 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
- import type { Select } from "hry-types/src/Object/Select";
3
2
  import type { AddNullForObject } from "../../../types/AddNullForObject";
4
3
  import type { InferDetailedType } from "../../../types/InferDetailedType";
5
- import type { PropertiesConstraint, RequiredSingle, RequiredType } from "./PropertiesConstraint";
4
+ import type { RequiredSingle, RequiredType } from "./PropertiesConstraint";
6
5
 
7
6
  /**
8
7
  * 获取properties必传字段的文档类型
9
- * @remarks 小程序中必传字段如果是object,默认类型为null,所以文档类型要联合上null类型
8
+ * @remarks 小程序中必传字段如果是object,默认类型为null,所以组件文档对象类型要联合上null类型
10
9
  */
11
10
  export type GetRequiredDoc<
12
- TProperties extends PropertiesConstraint,
11
+ TProperties extends Record<string, RequiredType>,
13
12
  TIsPage extends boolean,
14
- // @ts-ignore
15
- Required extends Record<string, RequiredType> = Select<TProperties, RequiredType>,
16
13
  > = {
17
- [k in keyof Required]: IfExtends<
18
- Required[k],
14
+ -readonly [k in keyof TProperties]: IfExtends<
15
+ TProperties[k],
16
+ // 非对象写法
19
17
  RequiredSingle,
20
- IfExtends<false, TIsPage, AddNullForObject<InferDetailedType<Required[k]>>, InferDetailedType<Required[k]>>,
21
18
  IfExtends<
22
19
  false,
23
20
  TIsPage,
24
- // @ts-ignore Required[k] 必为 RequiredUnion
25
- | AddNullForObject<InferDetailedType<Required[k]["type"]>>
26
- // @ts-ignore Required[k] 必为 RequiredUnion
27
- | AddNullForObject<InferDetailedType<Required[k]["optionalTypes"][number]>>,
28
- // @ts-ignore Required[k] 必为 RequiredUnion
29
- InferDetailedType<Required[k]["type"]> | InferDetailedType<Required[k]["optionalTypes"][number]>
21
+ // 组件的对象类型加null
22
+ AddNullForObject<InferDetailedType<TProperties[k]>>,
23
+ // 页面的对象类型不加null
24
+ InferDetailedType<TProperties[k]>
25
+ >,
26
+ // 对象写法 RequiredUnion
27
+ IfExtends<
28
+ false,
29
+ TIsPage,
30
+ // 组件的对象类型加null
31
+ AddNullForObject<
32
+ // @ts-ignore TProperties[k] 必为 RequiredUnion
33
+ | InferDetailedType<TProperties[k]["type"]>
34
+ // @ts-ignore TProperties[k] 必为 RequiredUnion
35
+ | InferDetailedType<TProperties[k]["optionalTypes"][number]>
36
+ >,
37
+ // 页面的对象类型不加null
38
+ // @ts-ignore TProperties[k] 必为 RequiredUnion
39
+ InferDetailedType<TProperties[k]["type"]> | InferDetailedType<TProperties[k]["optionalTypes"][number]>
30
40
  >
31
41
  >;
32
42
  };
@@ -1,3 +1,4 @@
1
+ import { Checking, type Test } from "hry-types";
1
2
  import { observable } from "mobx";
2
3
  import { RootComponent } from "../..";
3
4
  const user = observable({
@@ -5,9 +6,18 @@ const user = observable({
5
6
  age: 20,
6
7
  });
7
8
 
8
- RootComponent()({
9
+ const storeDoc = RootComponent()({
9
10
  store: {
10
11
  userName: () => user.name,
11
12
  userAge: () => user.age,
12
13
  },
13
14
  });
15
+
16
+ type StoreDocExpected = {
17
+ store: {
18
+ userName: string;
19
+ userAge: number;
20
+ };
21
+ };
22
+
23
+ Checking<typeof storeDoc, StoreDocExpected, Test.Pass>;
@@ -2,7 +2,8 @@ import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
2
  import type { NoInfer } from "hry-types/src/Generic/NoInfer";
3
3
  import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
4
4
  import type { Func } from "hry-types/src/Misc/Func";
5
- import type { ComputeIntersectionDeep } from "hry-types/src/Object/_api";
5
+ import type { ComputeIntersection } from "hry-types/src/Object/_api";
6
+ import type { ComputeObject } from "../../types/ComputeObj";
6
7
  import type { WMCompOtherOption, WMCompPageLifetimes, WMPageLifetimes } from "../../types/OfficialTypeAlias";
7
8
  import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
8
9
  import type { ComputedConstraint } from "./Computed/ComputedConstraint";
@@ -111,16 +112,16 @@ type RootComponentConstructor<TReceivedComponentDoc extends ComponentDoc[] | Com
111
112
  StoreDoc,
112
113
  ComputedDoc
113
114
  >,
114
- ): // 返回类型 RootComponentDoc
115
- ComputeIntersectionDeep<
115
+ ): // 返回类型 satisfies RootComponentDoc
116
+ ComputeIntersection<
116
117
  & IfExtends<TIsPage, false, {}, { isPage: true }>
117
118
  & IfExtends<EmptyObject, PropertiesDoc, {}, { properties: PropertiesDoc }>
118
119
  & IfExtends<EmptyObject, DataDoc, {}, { data: DataDoc }>
119
- & IfExtends<EmptyObject, StoreDoc, {}, { store: StoreDoc }>
120
+ & IfExtends<EmptyObject, StoreDoc, {}, { store: ComputeObject<StoreDoc> }>
120
121
  & IfExtends<EmptyObject, ComputedDoc, {}, { computed: ComputedDoc }>
121
122
  & IfExtends<EmptyObject, TMethods, {}, { methods: TMethods }>
122
123
  & IfExtends<EmptyObject, EventsDoc, {}, { events: EventsDoc }>
123
- & IfExtends<EmptyObject, CustomEventsDoc, {}, { customEvents: CustomEventsDoc }>
124
+ & IfExtends<EmptyObject, CustomEventsDoc, {}, { customEvents: ComputeObject<CustomEventsDoc> }>
124
125
  >;
125
126
  };
126
127
 
@@ -1,7 +1,7 @@
1
1
  import { Checking, type Test } from "hry-types";
2
2
  import type { ReadonlyDeep } from "hry-types/src/Any/_api";
3
3
  import type { Wm } from "../../../../thirdLib";
4
- import type { CompDocExtends } from "../../../../types/CompDocExtends";
4
+ import type { ComponentDocExtension } from "../../../../types/ComponentDocExtension";
5
5
  import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc";
6
6
 
7
7
  import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
@@ -28,7 +28,10 @@ SubComponent<{}, CompDoc>()({
28
28
  });
29
29
 
30
30
  // 2. 使用CompDocExtends泛型拓展组件文档,满足内部组件内部包含一些slot或基本组件数据
31
- type viewExtends = CompDocExtends<Wm.View, { view_obj: Mock_User | null; view_str: string; view_ddd: number }>;
31
+ type viewExtends = ComponentDocExtension<
32
+ Wm.View,
33
+ { properties: { view_obj: Mock_User | null; view_str: string; view_ddd: number } }
34
+ >;
32
35
 
33
36
  const res = SubComponent<{}, viewExtends>()({
34
37
  inherit: {
@@ -1,7 +1,7 @@
1
1
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
2
  import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
3
3
  import type { RequiredKeys } from "hry-types/src/Object/RequiredKeys";
4
- import type { ExtractDocPrefix } from "../../types/GetComponentPrefix";
4
+ 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
 
@@ -95,7 +95,7 @@ type SubComponentConstructor<
95
95
  TSupplementalPrefix extends string = "",
96
96
  IsPage extends boolean = TRootDoc["isPage"] extends true ? true : false,
97
97
  // 重构子组件的前缀
98
- CurrentPrefix extends string = `${ExtractDocPrefix<TOriginalCompDoc>}${Capitalize<TSupplementalPrefix>}`,
98
+ CurrentPrefix extends string = `${GetComponentPrefix<TOriginalCompDoc>}${Capitalize<TSupplementalPrefix>}`,
99
99
  // 更新原始文档的前缀为Prefix
100
100
  CurrentCompDoc extends ComponentDoc = IfExtends<
101
101
  TSupplementalPrefix,
package/src/index.ts CHANGED
@@ -1,7 +1,3 @@
1
- export type { Vant, Wm } from "./thirdLib";
2
-
3
- export type { Dataset, Detail, WMBaseEvent, WMCustomEvent } from "./types/OfficialTypeAlias";
4
-
5
1
  import { navigateTo } from "./api/navigateTo";
6
2
 
7
3
  import { DefineComponent } from "./api/DefineComponent";
@@ -12,10 +8,15 @@ import { SubComponent } from "./api/SubComponent";
12
8
 
13
9
  import type { DetailedType } from "./types/DetailedType";
14
10
 
11
+ import type { ComponentDocExtension } from "./types/ComponentDocExtension";
15
12
  import type { GenerateDoc } from "./types/GenerateDoc";
16
13
  import type { ParamsEqual } from "./types/TwoParamsEqual";
14
+ export type { Vant, Wm } from "./thirdLib";
15
+
16
+ export type { Dataset, Detail, WMBaseEvent, WMCustomEvent } from "./types/OfficialTypeAlias";
17
17
 
18
18
  export {
19
+ type ComponentDocExtension,
19
20
  DefineComponent,
20
21
  type DetailedType,
21
22
  type GenerateDoc,
@@ -0,0 +1,36 @@
1
+ import type { IfExtends } from "hry-types/src/Any/IfExtends";
2
+ import type { ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
3
+ import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
4
+ import type { GetComponentPrefix } from "./GetComponentPrefix";
5
+
6
+ type Validator<
7
+ TOriginalComponentDoc extends ComponentDoc,
8
+ TExtensionDoc extends ComponentDoc,
9
+ TOriginalPrefix extends PropertyKey = GetComponentPrefix<TOriginalComponentDoc>,
10
+ TExtenstionPrefix extends PropertyKey = GetComponentPrefix<TExtensionDoc>,
11
+ DuplicateKeys extends PropertyKey =
12
+ | Extract<keyof TExtensionDoc["properties"], keyof TOriginalComponentDoc["properties"]>
13
+ | Extract<keyof TExtensionDoc["customEvents"], keyof TOriginalComponentDoc["customEvents"]>,
14
+ > = IfExtends<
15
+ TOriginalPrefix,
16
+ TExtenstionPrefix,
17
+ IfExtends<DuplicateKeys, never, ComponentDoc, `${DuplicateKeys & string}字段重复`>,
18
+ `前缀错误,应为${TOriginalPrefix & string}`
19
+ >;
20
+
21
+ /**
22
+ * 有时组件文档内部包含一些slot或基本组件,可通过CompDocExtends泛型拓展组件文档,使得类型更安全
23
+ */
24
+ export type ComponentDocExtension<
25
+ TOriginalComponentDoc extends ComponentDoc,
26
+ // @ts-ignore
27
+ TExtensionDoc extends Validator<TOriginalComponentDoc, TExtensionDoc>,
28
+ > = ComputeIntersectionDeep<TOriginalComponentDoc & TExtensionDoc>;
29
+
30
+ // type test0 = ComponentDocExtension<{ properties: { aaa_xxx: string } }, { properties: { aaa_xxx: string } }>; // => "aaa_xxx字段重复"
31
+
32
+ // type test1 = ComponentDocExtension<{ customEvents: { aaa_xxx: string } }, { customEvents: { aaa_xxx: string } }>; // => "aaa_xxx字段重复"
33
+
34
+ // type test2 = ComponentDocExtension<{ properties: { aaa_xxx: string } }, { properties: { ddd_xxx: string } }>; // => "前缀错误,应为aaa"
35
+
36
+ // type test3 = ComponentDocExtension<{ customEvents: { aaa_xxx: string } }, { customEvents: { ddd_xxx: string } }>; // => "前缀错误,应为aaa"
@@ -0,0 +1 @@
1
+ export type ComputeObject<T> = T extends unknown ? { [k in keyof T]: T[k] } : never;
@@ -1,34 +1,36 @@
1
1
  // import { Checking, type Test } from "hry-types";
2
2
  import type { IfExtends } from "hry-types/src/Any/IfExtends";
3
+ import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
3
4
  import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
4
5
 
5
6
  /**
6
7
  * 提取文档前缀名
7
- * @param TComponentDoc - ComponentDoc
8
8
  */
9
- export type ExtractDocPrefix<TComponentDoc extends ComponentDoc> = keyof IfExtends<
10
- unknown,
11
- TComponentDoc["properties"],
12
- TComponentDoc["customEvents"],
13
- TComponentDoc["properties"]
14
- > extends `${infer P}_${string}` ? P
15
- : "";
9
+ export type GetComponentPrefix<TComponentDoc extends ComponentDoc> = EmptyObject extends TComponentDoc ? never
10
+ : keyof IfExtends<
11
+ unknown,
12
+ TComponentDoc["properties"],
13
+ TComponentDoc["customEvents"],
14
+ TComponentDoc["properties"]
15
+ > extends `${infer P}_${string}` ? P
16
+ : never;
16
17
 
17
- // type Test1 = ExtractDocPrefix<{ properties: { xxx_name: string } }>;
18
+ // type Test1 = GetComponentPrefix<{ properties: { xxx_name: string } }>;
18
19
 
19
20
  // type Test1Expect = "xxx";
20
21
 
21
22
  // Checking<Test1, Test1Expect, Test.Pass>;
22
23
 
23
- // type Test2 = ExtractDocPrefix<{ customEvents: { xxx_name: string } }>;
24
+ // type Test2 = GetComponentPrefix<{ customEvents: { xxx_name: string } }>;
24
25
 
25
26
  // type Test2Expect = "xxx";
26
27
 
27
28
  // Checking<Test2, Test2Expect, Test.Pass>;
28
29
 
29
- // // type lll = never extends `${infer P}_${string}` ? P: ""; // => string bug?
30
- // type Test3 = ExtractDocPrefix<{}>;
30
+ // type demo = never extends `${infer P}_${string}` ? P : ""; // => string why?
31
31
 
32
- // type Test3Expect = string;
32
+ // type Test3 = GetComponentPrefix<{}>;
33
+
34
+ // type Test3Expect = never;
33
35
 
34
36
  // Checking<Test3, Test3Expect, Test.Pass>;
@@ -1,8 +0,0 @@
1
- import type { ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
2
- import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
3
- import type { UnionToComma } from "./UnionToComma.test";
4
- type _Validator<T, ExistingKeys extends PropertyKey, DuplicateKeys extends PropertyKey = Extract<keyof T, ExistingKeys>> = [DuplicateKeys] extends [never] ? object : `重复的字段${UnionToComma<DuplicateKeys & string>}`;
5
- export type CompDocExtends<TSubComp extends ComponentDoc, Ext extends _Validator<Ext, keyof (TSubComp["properties"])> = {}> = ComputeIntersectionDeep<TSubComp & {
6
- properties: Ext;
7
- }>;
8
- export {};
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=CompDocExtends.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CompDocExtends.js","sourceRoot":"","sources":["../../src/types/CompDocExtends.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import type { Equals } from "hry-types/src/Any/Equals";
2
- export type Drop<T extends unknown[], A> = T extends [infer Head, ...infer Rest] ? Equals<A, Head> extends true ? Rest : Drop<[...Rest, Head], A> : T;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Drop.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Drop.js","sourceRoot":"","sources":["../../src/types/Drop.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- export type DropStr<S1 extends string, S2 extends string> = S1 extends `${infer Head}${S2}${infer Tail}` ? DropStr<`${Head}${Tail}`, S2> : S1;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=DropStr.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropStr.js","sourceRoot":"","sources":["../../src/types/DropStr.ts"],"names":[],"mappings":""}
File without changes
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=RestorePropertiesDoc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RestorePropertiesDoc.js","sourceRoot":"","sources":["../../src/types/RestorePropertiesDoc.ts"],"names":[],"mappings":""}
@@ -1,14 +0,0 @@
1
- import type { ComputeIntersectionDeep } from "hry-types/src/Object/ComputeIntersectionDeep";
2
- import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc";
3
- import type { UnionToComma } from "./UnionToComma.test";
4
-
5
- type _Validator<
6
- T,
7
- ExistingKeys extends PropertyKey,
8
- DuplicateKeys extends PropertyKey = Extract<keyof T, ExistingKeys>,
9
- > = [DuplicateKeys] extends [never] ? object : `重复的字段${UnionToComma<DuplicateKeys & string>}`;
10
-
11
- export type CompDocExtends<
12
- TSubComp extends ComponentDoc,
13
- Ext extends _Validator<Ext, keyof (TSubComp["properties"])> = {},
14
- > = ComputeIntersectionDeep<TSubComp & { properties: Ext }>;
package/src/types/Drop.ts DELETED
@@ -1,18 +0,0 @@
1
- import type { Equals } from "hry-types/src/Any/Equals";
2
-
3
- /**
4
- * 从' T '中删除' A '项
5
- * @param T - 元组类型
6
- * @param A - 任意类型
7
- * @returns [[unknown[]]]
8
- * @example
9
- */
10
- export type Drop<T extends unknown[], A> = T extends [infer Head, ...infer Rest]
11
- ? Equals<A, Head> extends true ? Rest : Drop<[...Rest, Head], A>
12
- : T;
13
-
14
- // // type Test = Drop<[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3>[number];
15
-
16
- // // type TestExpect = [4, 5, 6, 8, 7, 9, 10, 1, 2][number];
17
-
18
- // // Checking<Test, TestExpect, Test.Pass>;
@@ -1,5 +0,0 @@
1
- export type DropStr<S1 extends string, S2 extends string> = S1 extends `${infer Head}${S2}${infer Tail}`
2
- ? DropStr<`${Head}${Tail}`, S2>
3
- : S1;
4
-
5
- // type lll = DropStr<"CatchAAACatchff", "Catch">; //=> "AAAff"
@@ -1,26 +0,0 @@
1
- // import type { ComponentDoc } from "../api/DefineComponent/CreateDoc/ComponentDoc";
2
- // import type { Drop } from "./Drop";
3
-
4
- // import type { ListOfSamePrimitive } from "./ListOfSamePrimitive";
5
- // import type { ReStorePropTypeOfList } from "./ReStorePropTypeOfList";
6
- // import type { DetailedType } from "./DetailedType";
7
-
8
- /**
9
- * 还原properties描述
10
- * @example
11
- * ```ts
12
- * type doc = {properties:{a:'1'|'2',b:boolean,c:string[],d:{name:string}}}
13
- * type test = ReStorePropertiesDoc<doc>
14
- * //=> {a: "1" | "2" | {type: "1" | "2"; value?: "1" | "2";}; b: boolean | {type: boolean; value?: boolean;}; c: string[] | {type: string[]; value?: string[];}; d: {name: string;} | {type: {name: string;}; value?: {name: string;};}}
15
- * ```
16
- */
17
- // type ReStorePropertiesDoc<T extends ComponentDoc> = {
18
- // [k in keyof T]?: ListOfSamePrimitive<T[k]> extends infer R extends unknown[]
19
- // ? R["length"] extends 1 ? DetailedType<R[0]> | { type: DetailedType<R[0]>; value: R[0] }
20
- // : {
21
- // type: DetailedType<R[0]>;
22
- // value?: R[0];
23
- // optionalTypes?: ReStorePropTypeOfList<Drop<R, R[0]>>[number][];
24
- // }
25
- // : never;
26
- // };