annil 1.8.2 → 1.8.3

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.8.3](https://github.com/missannil/annil/compare/v1.8.2...v1.8.3) (2024-09-08)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * 为subComponents内部组件类型增加 prefix_isReady?:boolean 字段。 ([e78041d](https://github.com/missannil/annil/commit/e78041d5f151d71c1d45652b0508aa4c2430ecde))
13
+
7
14
  ## [1.8.2](https://github.com/missannil/annil/compare/v1.8.1...v1.8.2) (2024-09-07)
8
15
 
9
16
 
@@ -3,9 +3,9 @@ import { computedUpdater } from "./computedUpdater";
3
3
  import { getPathsValue } from "./getPathsValue";
4
4
  import { getPropertiesValue } from "./getPropertiesValue";
5
5
  import { initComputedAndGetCache } from "./initComputedAndGetCache";
6
- import { assertNonNullable } from "../../../../utils/assertNonNullable";
7
6
  import { deepClone } from "../../../../utils/deepClone";
8
7
  import { isEmptyObject } from "../../../../utils/isEmptyObject";
8
+ import { nonNullable } from "../../../../utils/nonNullable";
9
9
  function initWatchOldValue(data, watchConfig) {
10
10
  const watchOldValue = {};
11
11
  for (const key in watchConfig) {
@@ -47,7 +47,7 @@ export function computedWatchHandle(options) {
47
47
  // 在监控多个数据时,参数是多个值
48
48
  observersConfig[key] = function (...newValue) {
49
49
  originObserversHandle === null || originObserversHandle === void 0 ? void 0 : originObserversHandle.call(this, ...newValue);
50
- const watchOldValue = assertNonNullable(this.data.__watchOldValue__);
50
+ const watchOldValue = nonNullable(this.data.__watchOldValue__);
51
51
  const oldValue = watchOldValue[key];
52
52
  if (deepEqual(newValue, oldValue))
53
53
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sour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AAE,OAAO;gBAC1C,aAAa,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;gBAEzC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC;YAClD,CAAC,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/normalizeOptions/computedWatchHandle/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAM5D,SAAS,iBAAiB,CAAC,IAAqC,EAAE,WAAmB;IACnF,MAAM,aAAa,GAAG,EAAE,CAAC;IACzB,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,kBAAkB;QAClB,aAAa,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AACD,MAAM,UAAU,mBAAmB,CAAC,OAAgC;IAClE,iBAAiB;IACjB,MAAM,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IACxC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAClE,IAAI,cAAc,IAAI,CAAC,aAAa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AAI,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC;gBAE/C,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;gBAC/D,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;gBAEpC,IAAI,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC;oBAAE,OAAO;gBAC1C,aAAa,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;gBAEzC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC;YAClD,CAAC,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -3,6 +3,7 @@ import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
3
3
  import type { Func } from "hry-types/src/Misc/Func";
4
4
  import type { RequiredKeys } from "hry-types/src/Object/RequiredKeys";
5
5
  import type { ComputeObject } from "../../types/ComputeObj";
6
+ import type { Extra } from "../../types/Extra";
6
7
  import type { GetComponentPrefix } from "../../types/GetComponentPrefix";
7
8
  import type { InnerFields } from "../../types/InnerData";
8
9
  import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
@@ -40,7 +41,12 @@ import type { SubWatchOption } from "./SubWatch/SubWatchOption";
40
41
  type Options<RootDoc extends RootComponentType, IsPage extends boolean, CurrentCompDoc extends ComponentType, 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, CompDocKeys extends PropertyKey = keyof CurrentCompDoc["properties"]> = SubInheritOption<TInherit, CompDocKeys> & SubDataOption<TSubData, Exclude<CompDocKeys, (keyof InheritDoc)> | InnerFields<Prefix>> & SubStoreOption<TSubStore, Exclude<CompDocKeys, (keyof (InheritDoc & SubDataDoc))> | InnerFields<Prefix>> & SubComputedOption<TSubComputed, Exclude<CompDocKeys, (keyof (InheritDoc & SubDataDoc & SubStoreDoc))> | InnerFields<Prefix>, {
41
42
  data: ComputeObject<AllRootDataDoc & Replace<SubComputedDoc, Required<CurrentCompDoc["properties"]>> & SubStoreDoc & SubDataDoc & IInjectAllData>;
42
43
  }> & SubEventsOption<TEvents, SubEventsDoc, keyof SubEventsConstraint<CurrentCompDoc>> & SubMethodsOption<TSubMethods, Prefix, keyof (CurrentCompDoc["customEvents"] & SubEventsDoc)> & SubPageLifetimesOption<IsPage, NonNullable<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"], Replace<SubDataDoc, Required<CurrentCompDoc["properties"]>>, AllRootDataDoc & Replace<SubDataDoc & SubComputedDoc & SubStoreDoc, Required<CurrentCompDoc["properties"]>>, NonNullable<RootDoc["customEvents"]>, SubStoreDoc>>;
43
- type SubComponentConstructor<TRootDoc extends RootComponentType, TOriginalCompDoc extends ComponentType, TSupplementalPrefix extends string = "", IsPage extends boolean = TRootDoc["isPage"] extends true ? true : false, CurrentPrefix extends string = `${GetComponentPrefix<TOriginalCompDoc>}${Capitalize<TSupplementalPrefix>}`, CurrentCompDoc extends ComponentType = IfExtends<TSupplementalPrefix, "", TOriginalCompDoc, ReplacePrefix<TOriginalCompDoc, CurrentPrefix>>, AllRootDataDoc extends object = Required<TRootDoc["properties"]> & TRootDoc["data"] & TRootDoc["computed"] & TRootDoc["store"]> = <TInherit extends InheritConstraint<AllRootDataDoc, CurrentCompDoc>, TSubData extends SubDataConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof InheritDoc> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubStore extends SubStoreConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc)> & Record<InnerFields<CurrentPrefix>, unknown>>, TEvents extends SubEventsConstraint<CurrentCompDoc>, TSubComputed extends SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubMethods extends SubMethodsConstraint = {}, InheritDoc extends object = IfExtends<InheritConstraint<AllRootDataDoc, CurrentCompDoc>, TInherit, {}, TInherit>, SubDataDoc extends object = IfExtends<SubDataConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof InheritDoc> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubData, {}, TSubData>, SubStoreDoc extends object = IfExtends<SubStoreConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc)> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubStore, {}, {
44
+ type SubComponentConstructor<TRootDoc extends RootComponentType, TOriginalCompDoc extends ComponentType, TSupplementalPrefix extends string = "", IsPage extends boolean = TRootDoc["isPage"] extends true ? true : false, CurrentPrefix extends string = `${GetComponentPrefix<TOriginalCompDoc>}${Capitalize<TSupplementalPrefix>}`, CurrentCompDoc extends ComponentType = IfExtends<TSupplementalPrefix, "", TOriginalCompDoc & {
45
+ properties: Extra<CurrentPrefix>;
46
+ }, // 为文档增加格外字段
47
+ ReplacePrefix<TOriginalCompDoc & {
48
+ properties: Extra<CurrentPrefix>;
49
+ }, CurrentPrefix>>, AllRootDataDoc extends object = Required<TRootDoc["properties"]> & TRootDoc["data"] & TRootDoc["computed"] & TRootDoc["store"]> = <TInherit extends InheritConstraint<AllRootDataDoc, CurrentCompDoc>, TSubData extends SubDataConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof InheritDoc> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubStore extends SubStoreConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc)> & Record<InnerFields<CurrentPrefix>, unknown>>, TEvents extends SubEventsConstraint<CurrentCompDoc>, TSubComputed extends SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubMethods extends SubMethodsConstraint = {}, InheritDoc extends object = IfExtends<InheritConstraint<AllRootDataDoc, CurrentCompDoc>, TInherit, {}, TInherit>, SubDataDoc extends object = IfExtends<SubDataConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof InheritDoc> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubData, {}, TSubData>, SubStoreDoc extends object = IfExtends<SubStoreConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc)> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubStore, {}, {
44
50
  [k in keyof TSubStore]: ReturnType<NonNullable<TSubStore[k]>>;
45
51
  }>, SubComputedDoc extends object = IfExtends<SubComputedConstraint<Omit<Required<CurrentCompDoc["properties"]>, keyof (InheritDoc & SubDataDoc & SubStoreDoc)> & Record<InnerFields<CurrentPrefix>, unknown>>, TSubComputed, {}, GetSubComputedDoc<TSubComputed>>, SubEventsDoc extends object = IfExtends<SubEventsConstraint<CurrentCompDoc>, TEvents, {}, TEvents>, SubMethodsDoc extends object = TSubMethods, MissingRequiredField extends PropertyKey = Exclude<RequiredKeys<NonNullable<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<NonNullable<CurrentCompDoc["customEvents"]>, SubEventsDoc, MissingRequiredField>;
46
52
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/SubComponent/index.ts"],"names":[],"mappings":"AA2OA;;;GAGG;AACH,MAAM,UAAU,YAAY;IAK1B,8DAA8D;IAC9D,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAkC,CAAQ,CAAC;AACvE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/SubComponent/index.ts"],"names":[],"mappings":"AA4OA;;;GAGG;AACH,MAAM,UAAU,YAAY;IAK1B,8DAA8D;IAC9D,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAkC,CAAQ,CAAC;AACvE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type Extra<Prefix extends string> = {
2
+ [K in `${Prefix}_isReady`]?: boolean;
3
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Extra.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Extra.js","sourceRoot":"","sources":["../../src/types/Extra.ts"],"names":[],"mappings":""}
@@ -1,7 +1,7 @@
1
- import { assertNonNullable } from "./assertNonNullable";
2
1
  import { debounce } from "./debounce";
3
2
  import { deepClone } from "./deepClone";
4
3
  import { deepEqual } from "./deepEqual";
5
4
  import { isEmptyObject } from "./isEmptyObject";
5
+ import { nonNullable } from "./nonNullable";
6
6
  import { throttle } from "./throttle";
7
- export { assertNonNullable, debounce, deepClone, deepEqual, isEmptyObject, throttle };
7
+ export { debounce, deepClone, deepEqual, isEmptyObject, nonNullable, throttle };
@@ -1,8 +1,8 @@
1
- import { assertNonNullable } from "./assertNonNullable";
2
1
  import { debounce } from "./debounce";
3
2
  import { deepClone } from "./deepClone";
4
3
  import { deepEqual } from "./deepEqual";
5
4
  import { isEmptyObject } from "./isEmptyObject";
5
+ import { nonNullable } from "./nonNullable";
6
6
  import { throttle } from "./throttle";
7
- export { assertNonNullable, debounce, deepClone, deepEqual, isEmptyObject, throttle };
7
+ export { debounce, deepClone, deepEqual, isEmptyObject, nonNullable, throttle };
8
8
  //# sourceMappingURL=_utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_utils.js","sourceRoot":"","sources":["../../src/utils/_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"_utils.js","sourceRoot":"","sources":["../../src/utils/_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC"}
@@ -4,4 +4,4 @@ import type { IfContains } from "hry-types/src/Any/IfContains";
4
4
  * @param value 类型中必须包含 null 或 undefined
5
5
  * @returns 去除 null 和 undefined 后的类型
6
6
  */
7
- export declare function assertNonNullable<T>(value: IfContains<T, null | undefined, T, "参数类型必须包含 null 或 undefined">): NonNullable<T>;
7
+ export declare function nonNullable<T>(value: IfContains<T, null | undefined, T, "参数类型必须包含 null 或 undefined">): NonNullable<T>;
@@ -3,11 +3,11 @@
3
3
  * @param value 类型中必须包含 null 或 undefined
4
4
  * @returns 去除 null 和 undefined 后的类型
5
5
  */
6
- export function assertNonNullable(value) {
6
+ export function nonNullable(value) {
7
7
  /* istanbul ignore next */
8
8
  if (value === null || value === undefined) {
9
9
  throw new Error(`${value} should not be null or undefined`);
10
10
  }
11
11
  return value;
12
12
  }
13
- //# sourceMappingURL=assertNonNullable.js.map
13
+ //# sourceMappingURL=nonNullable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nonNullable.js","sourceRoot":"","sources":["../../src/utils/nonNullable.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,KAAsE;IAEtE,2BAA2B;IAC3B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,kCAAkC,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,KAAuB,CAAC;AACjC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "annil",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "description": "微信小程序(原生开发)插件",
5
5
  "main": "dist/index.js",
6
6
  "types": "src/index.ts",
@@ -17,7 +17,7 @@
17
17
  "tsc": "tsc --watch",
18
18
  "test": "jest --watch",
19
19
  "build": "tsc -p tsconfig.build.json",
20
- "check": "eslint . --fix --max-warnings 0 && (dprint check || (dprint fmt && exit 1)) "
20
+ "check": "tsc --noEmit && eslint . --fix --max-warnings 0 && (dprint check || (dprint fmt && exit 1)) "
21
21
  },
22
22
  "devDependencies": {
23
23
  "@commitlint/config-conventional": "^17.6.5",
@@ -5,9 +5,9 @@ import { getPathsValue } from "./getPathsValue";
5
5
  import { getPropertiesValue } from "./getPropertiesValue";
6
6
  import { initComputedAndGetCache } from "./initComputedAndGetCache";
7
7
 
8
- import { assertNonNullable } from "../../../../utils/assertNonNullable";
9
8
  import { deepClone } from "../../../../utils/deepClone";
10
9
  import { isEmptyObject } from "../../../../utils/isEmptyObject";
10
+ import { nonNullable } from "../../../../utils/nonNullable";
11
11
  import type { Instance } from "../../../RootComponent/Instance/RootComponentInstance";
12
12
  import type { FinalOptionsOfComponent } from "..";
13
13
 
@@ -68,7 +68,7 @@ export function computedWatchHandle(options: FinalOptionsOfComponent) {
68
68
  observersConfig[key] = function(this: Instance, ...newValue: unknown[]) {
69
69
  originObserversHandle?.call(this, ...newValue);
70
70
 
71
- const watchOldValue = assertNonNullable(this.data.__watchOldValue__);
71
+ const watchOldValue = nonNullable(this.data.__watchOldValue__);
72
72
  const oldValue = watchOldValue[key];
73
73
 
74
74
  if (deepEqual(newValue, oldValue)) return;
@@ -10,7 +10,7 @@ import type {
10
10
  WMBaseEvent,
11
11
  WMCustomEvent,
12
12
  } from "../../../../types/OfficialTypeAlias";
13
- import { assertNonNullable } from "../../../../utils/assertNonNullable";
13
+ import { nonNullable } from "../../../../utils/nonNullable";
14
14
  import type { ComponentType } from "../../../DefineComponent/ReturnType/ComponentType";
15
15
  import { RootComponent } from "../..";
16
16
  import type { Bubbles, Capture } from "../../CustomEvents/CustomEventsTag";
@@ -42,7 +42,7 @@ RootComponent()({
42
42
  ) {
43
43
  Checking<typeof e.detail, string, Test.Pass>;
44
44
 
45
- const markData = assertNonNullable(e.mark).markData;
45
+ const markData = nonNullable(e.mark).markData;
46
46
 
47
47
  Checking<typeof markData, { id: string }, Test.Pass>;
48
48
 
@@ -160,3 +160,11 @@ SubComponent<Root, $aaa>()({
160
160
  },
161
161
  },
162
162
  });
163
+ // computed中可写 额外字段 isReady
164
+ SubComponent<{ data: { _num: number } }, $aaa>()({
165
+ computed: {
166
+ aaa_isReady() {
167
+ return true;
168
+ },
169
+ },
170
+ });
@@ -48,7 +48,7 @@ SubComponent<{}, CompDoc>()({
48
48
  },
49
49
  methods: {
50
50
  aaa_1() {
51
- // 4 this.data中的data配置数据
51
+ // 4 this.data中的data配置数据类型应该与文档类型一致,比如aaa_str的类型为"a" | "b"而非string
52
52
  void Checking<
53
53
  typeof this.data,
54
54
  ComputeIntersection<
@@ -80,3 +80,9 @@ SubComponent<{ data: { _num: number } }, CompDoc>()({
80
80
  },
81
81
  },
82
82
  });
83
+ // data中可写 额外字段 isReady
84
+ SubComponent<{ data: { _num: number } }, CompDoc>()({
85
+ data: {
86
+ aaa_isReady: false,
87
+ },
88
+ });
@@ -28,3 +28,9 @@ SubComponent<{}, DocA, "a">()({
28
28
  _aaaA_xxx: () => user.age,
29
29
  },
30
30
  });
31
+ // store中可写 额外字段 isReady
32
+ SubComponent<{ data: { _num: number } }, DocA, "a">()({
33
+ store: {
34
+ aaaA_isReady: () => false,
35
+ },
36
+ });
@@ -3,6 +3,7 @@ import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
3
3
  import type { Func } from "hry-types/src/Misc/Func";
4
4
  import type { RequiredKeys } from "hry-types/src/Object/RequiredKeys";
5
5
  import type { ComputeObject } from "../../types/ComputeObj";
6
+ import type { Extra } from "../../types/Extra";
6
7
  import type { GetComponentPrefix } from "../../types/GetComponentPrefix";
7
8
  import type { InnerFields } from "../../types/InnerData";
8
9
  import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
@@ -125,8 +126,8 @@ type SubComponentConstructor<
125
126
  CurrentCompDoc extends ComponentType = IfExtends<
126
127
  TSupplementalPrefix,
127
128
  "",
128
- TOriginalCompDoc,
129
- ReplacePrefix<TOriginalCompDoc, CurrentPrefix>
129
+ TOriginalCompDoc & { properties: Extra<CurrentPrefix> }, // 为文档增加格外字段
130
+ ReplacePrefix<TOriginalCompDoc & { properties: Extra<CurrentPrefix> }, CurrentPrefix> // 为文档增加格外字段
130
131
  >,
131
132
  AllRootDataDoc extends object =
132
133
  // rootDoc中的properties是带有可选的,这是为了给使用者(上层组件)提示,而在自身组件实例中并不存在可选状态,故加了Required,正因加了Required使得最终结果不可能为unknown而是`{}`,满足object约束
@@ -1 +1 @@
1
- // export type Extra<Prefix extends string> = Record<`${Prefix}_isReady`, boolean>;
1
+ export type Extra<Prefix extends string> = { [K in `${Prefix}_isReady`]?: boolean };
@@ -1,8 +1,8 @@
1
- import { assertNonNullable } from "./assertNonNullable";
2
1
  import { debounce } from "./debounce";
3
2
  import { deepClone } from "./deepClone";
4
3
  import { deepEqual } from "./deepEqual";
5
4
  import { isEmptyObject } from "./isEmptyObject";
5
+ import { nonNullable } from "./nonNullable";
6
6
  import { throttle } from "./throttle";
7
7
 
8
- export { assertNonNullable, debounce, deepClone, deepEqual, isEmptyObject, throttle };
8
+ export { debounce, deepClone, deepEqual, isEmptyObject, nonNullable, throttle };
@@ -5,7 +5,7 @@ import type { IfContains } from "hry-types/src/Any/IfContains";
5
5
  * @param value 类型中必须包含 null 或 undefined
6
6
  * @returns 去除 null 和 undefined 后的类型
7
7
  */
8
- export function assertNonNullable<T>(
8
+ export function nonNullable<T>(
9
9
  value: IfContains<T, null | undefined, T, "参数类型必须包含 null 或 undefined">,
10
10
  ): NonNullable<T> {
11
11
  /* istanbul ignore next */
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertNonNullable.js","sourceRoot":"","sources":["../../src/utils/assertNonNullable.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAsE;IAEtE,2BAA2B;IAC3B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,kCAAkC,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,KAAuB,CAAC;AACjC,CAAC"}