Skip to content

Commit 21452e8

Browse files
committed
fix(types): make VEList a MaybeArray for array values
1 parent 73ee4a0 commit 21452e8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/next-safe-action/src/utils.types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ export type Prettify<T> = {
55

66
// Returns type or promise of type.
77
export type MaybePromise<T> = Promise<T> | T;
8+
9+
// Returns type or array of type.
10+
export type MaybeArray<T> = T | T[];

packages/next-safe-action/src/validation-errors.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { InferInputArray, InferInputOrDefault, StandardSchemaV1 } from "./standard-schema";
2-
import type { Prettify } from "./utils.types";
2+
import type { MaybeArray, Prettify } from "./utils.types";
33

44
// Basic types and arrays.
55
type NotObject = number | string | boolean | bigint | symbol | null | undefined | any[];
66

77
// Object with an optional list of validation errors.
8-
type VEList<K = undefined> = K extends any[] ? { _errors?: string[] }[] : { _errors?: string[] };
8+
type VEList<K = undefined> = K extends any[] ? MaybeArray<{ _errors?: string[] }> : { _errors?: string[] };
99

1010
// Creates nested schema validation errors type using recursion.
1111
type SchemaErrors<S> = {

0 commit comments

Comments
 (0)