Skip to content

Commit

Permalink
feat: remove object destructuring for clarity for now
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Nov 25, 2023
1 parent 3d08d08 commit 9678f82
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/vee-validate/src/types/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,5 +326,5 @@ export interface FormContext<TValues extends GenericObject = GenericObject, TOut
>(
path: MaybeRefOrGetter<TPath>,
config?: Partial<InputBindsConfig<TValue, TExtras>> | LazyInputBindsConfig<TValue, TExtras>,
): { model: Ref<TValue>; props: Ref<BaseFieldProps & TExtras> } & [Ref<TValue>, Ref<BaseFieldProps & TExtras>];
): [Ref<TValue>, Ref<BaseFieldProps & TExtras>];
}
9 changes: 1 addition & 8 deletions packages/vee-validate/src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ import {
normalizeErrorItem,
omit,
debounceNextTick,
makeDestructurable,
} from './utils';
import { FormContextKey } from './symbols';
import { validateTypedSchema, validateObjectSchema } from './validate';
Expand Down Expand Up @@ -1013,13 +1012,7 @@ export function useForm<

const model = createModel(path, () => evalConfig().validateOnModelUpdate ?? true);

return makeDestructurable(
{
model,
props,
},
[model, props] as [Ref<TValue>, Ref<BaseFieldProps & TExtras>],
);
return [model, props] as [Ref<TValue>, Ref<BaseFieldProps & TExtras>];
}

return {
Expand Down
20 changes: 0 additions & 20 deletions packages/vee-validate/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,23 +359,3 @@ export function debounceNextTick<
return new Promise<TResult>(resolve => resolves.push(resolve));
};
}

// https://github.com/vueuse/vueuse/blob/main/packages/shared/makeDestructurable/index.ts
export function makeDestructurable<T extends Record<string, unknown>, A extends readonly any[]>(obj: T, arr: A): T & A {
const clone = { ...obj };

Object.defineProperty(clone, Symbol.iterator, {
enumerable: false,
value() {
let index = 0;
return {
next: () => ({
value: arr[index++],
done: index > arr.length,
}),
};
},
});

return clone as T & A;
}

0 comments on commit 9678f82

Please sign in to comment.