From f74550c6e99fd63a2830b0a182e9e3cd410b04e9 Mon Sep 17 00:00:00 2001 From: Brain777777 <35163869+Brain777777@users.noreply.github.com> Date: Mon, 4 Jul 2022 16:10:11 +0800 Subject: [PATCH 1/6] feat: add type Many --- packages/shared/utils/types.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/shared/utils/types.ts b/packages/shared/utils/types.ts index 06a6707ab67..b8385f519f7 100644 --- a/packages/shared/utils/types.ts +++ b/packages/shared/utils/types.ts @@ -51,6 +51,8 @@ export type ShallowUnwrapRef = T extends Ref ? P : T export type Awaitable = Promise | T +export type Many = ReadonlyArray | T + export interface Pausable { /** * A ref indicate whether a pusable instance is active From 9f3d3478973a8504b64ff7d18ecc06aa63a08a0e Mon Sep 17 00:00:00 2001 From: Brain777777 <35163869+Brain777777@users.noreply.github.com> Date: Mon, 4 Jul 2022 16:12:23 +0800 Subject: [PATCH 2/6] fix: Pick Second parameter support Array --- packages/shared/reactivePick/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/shared/reactivePick/index.ts b/packages/shared/reactivePick/index.ts index a9a6e1e3b59..9b0a908f01e 100644 --- a/packages/shared/reactivePick/index.ts +++ b/packages/shared/reactivePick/index.ts @@ -1,5 +1,6 @@ import type { UnwrapRef } from 'vue-demi' import { reactive, toRef } from 'vue-demi' +import { Many } from '../utils' /** * Reactively pick fields from a reactive object @@ -8,7 +9,7 @@ import { reactive, toRef } from 'vue-demi' */ export function reactivePick( obj: T, - ...keys: K[] + ...keys: Array> ): { [S in K]: UnwrapRef } { return reactive(Object.fromEntries(keys.map(k => [k, toRef(obj, k)]))) as any } From c48e4807d16c84f53f598b565b7be0db7fd798d9 Mon Sep 17 00:00:00 2001 From: Brain777777 <35163869+Brain777777@users.noreply.github.com> Date: Mon, 4 Jul 2022 16:12:36 +0800 Subject: [PATCH 3/6] fix: Omit Second parameter support Array --- packages/shared/reactiveOmit/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/shared/reactiveOmit/index.ts b/packages/shared/reactiveOmit/index.ts index b15a2dbd843..b4a8eb96a24 100644 --- a/packages/shared/reactiveOmit/index.ts +++ b/packages/shared/reactiveOmit/index.ts @@ -1,5 +1,6 @@ import { toRefs } from 'vue-demi' import { reactiveComputed } from '../reactiveComputed' +import type { Many } from '../utils' /** * Reactively omit fields from a reactive object @@ -8,7 +9,7 @@ import { reactiveComputed } from '../reactiveComputed' */ export function reactiveOmit( obj: T, - ...keys: K[] + ...keys: Array> ): Omit { return reactiveComputed(() => Object.fromEntries(Object.entries(toRefs(obj)).filter(e => !keys.includes(e[0] as any)))) } From 6ad717c52a9f2944059494918b03b34d953a9393 Mon Sep 17 00:00:00 2001 From: Brain777 <827421256@qq.com> Date: Mon, 4 Jul 2022 19:50:52 +0800 Subject: [PATCH 4/6] chore: remove Many type --- packages/shared/utils/types.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/shared/utils/types.ts b/packages/shared/utils/types.ts index b8385f519f7..06a6707ab67 100644 --- a/packages/shared/utils/types.ts +++ b/packages/shared/utils/types.ts @@ -51,8 +51,6 @@ export type ShallowUnwrapRef = T extends Ref ? P : T export type Awaitable = Promise | T -export type Many = ReadonlyArray | T - export interface Pausable { /** * A ref indicate whether a pusable instance is active From a651806099e51f8fc03adc6fe18b90c1357ce63c Mon Sep 17 00:00:00 2001 From: Brain777 <827421256@qq.com> Date: Mon, 4 Jul 2022 19:59:42 +0800 Subject: [PATCH 5/6] refactor: Delete `Many` and replace them with literal forms --- packages/shared/reactiveOmit/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/shared/reactiveOmit/index.ts b/packages/shared/reactiveOmit/index.ts index b4a8eb96a24..7793dcea49d 100644 --- a/packages/shared/reactiveOmit/index.ts +++ b/packages/shared/reactiveOmit/index.ts @@ -1,6 +1,5 @@ import { toRefs } from 'vue-demi' import { reactiveComputed } from '../reactiveComputed' -import type { Many } from '../utils' /** * Reactively omit fields from a reactive object @@ -9,7 +8,7 @@ import type { Many } from '../utils' */ export function reactiveOmit( obj: T, - ...keys: Array> + ...keys: (K | K[])[] ): Omit { return reactiveComputed(() => Object.fromEntries(Object.entries(toRefs(obj)).filter(e => !keys.includes(e[0] as any)))) } From 2fb6b0dfe41f5390b51743c254974dfb925cca54 Mon Sep 17 00:00:00 2001 From: Brain777 <827421256@qq.com> Date: Mon, 4 Jul 2022 20:00:43 +0800 Subject: [PATCH 6/6] refactor: Delete `Many` and replace them with literal forms --- packages/shared/reactivePick/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/shared/reactivePick/index.ts b/packages/shared/reactivePick/index.ts index 9b0a908f01e..c7f352d48b4 100644 --- a/packages/shared/reactivePick/index.ts +++ b/packages/shared/reactivePick/index.ts @@ -1,6 +1,5 @@ import type { UnwrapRef } from 'vue-demi' import { reactive, toRef } from 'vue-demi' -import { Many } from '../utils' /** * Reactively pick fields from a reactive object @@ -9,7 +8,7 @@ import { Many } from '../utils' */ export function reactivePick( obj: T, - ...keys: Array> + ...keys: (K | K[])[] ): { [S in K]: UnwrapRef } { return reactive(Object.fromEntries(keys.map(k => [k, toRef(obj, k)]))) as any }