Skip to content

Add a way for .superRefine() to narrow down the output type #1602

@DanielBreiner

Description

@DanielBreiner

Currently, refine has a type guard which is used to narrow down the output type.

refine<RefinedOutput extends Output>(
  check: (arg: Output) => arg is RefinedOutput,
  message?: /* ... */
): ZodEffects<this, RefinedOutput, RefinedOutput>;

superRefine: (
  refinement: RefinementEffect<Output>["refinement"]
) => ZodEffects<this, Output, Input>;

I propose adding this functionality to superRefine as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions