Skip to content

Commit 53e1de3

Browse files
committed
fix(vee-validate): move '' from Path to FromErrors and FormErrorBag
The `''` type only makes sense for errors (the top level errors). But the Path type is also used in other places so it shouldn't add it.
1 parent 6144487 commit 53e1de3

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

packages/vee-validate/src/types/forms.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ export interface FormState<TValues> {
182182
submitCount: number;
183183
}
184184

185-
export type FormErrors<TValues extends GenericObject> = Partial<Record<Path<TValues>, string | undefined>>;
186-
export type FormErrorBag<TValues extends GenericObject> = Partial<Record<Path<TValues>, string[]>>;
185+
export type FormErrors<TValues extends GenericObject> = Partial<Record<Path<TValues> | '', string | undefined>>;
186+
export type FormErrorBag<TValues extends GenericObject> = Partial<Record<Path<TValues> | '', string[]>>;
187187

188188
export interface ResetFormOpts {
189189
force: boolean;

packages/vee-validate/src/types/paths.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ type PathInternalArray<TValue extends ReadonlyArray<any>, TraversedTypes> =
9696
*/
9797
type PathInternalObject<TValue, TraversedTypes, First extends boolean> = {
9898
[Key in keyof TValue & string]: First extends true
99-
? '' | `${Key}` | `${Key}${PathInternal<TValue[Key], TraversedTypes, false>}`
99+
? `${Key}` | `${Key}${PathInternal<TValue[Key], TraversedTypes, false>}`
100100
: `.${Key}` | `.${Key}${PathInternal<TValue[Key], TraversedTypes, false>}`;
101101
}[keyof TValue & string];
102102

@@ -105,11 +105,7 @@ type PathInternalObject<TValue, TraversedTypes, First extends boolean> = {
105105
*
106106
* See {@link Path}
107107
*/
108-
type PathInternalAny<First extends boolean> =
109-
| (First extends true ? '' : never)
110-
| `.${string}`
111-
| `[${string}]`
112-
| `[${string}].${string}`;
108+
type PathInternalAny = `.${string}` | `[${string}]` | `[${string}].${string}`;
113109

114110
/**
115111
* Helper type for recursively constructing paths through a type.
@@ -120,7 +116,7 @@ type PathInternalAny<First extends boolean> =
120116
*/
121117
type PathInternal<TValue, TraversedTypes, First extends boolean> = TValue extends Primitive | BrowserNativeObject
122118
? IsAny<TValue> extends true
123-
? PathInternalAny<First>
119+
? PathInternalAny
124120
: never
125121
: TValue extends ReadonlyArray<any>
126122
? // Check so that we don't recurse into the same type by ensuring that the

0 commit comments

Comments
 (0)