Skip to content

.partial() silently drops .narrow() predicate (similar to #1468) #1596

@yiidtw

Description

@yiidtw

Similar to #1468 where spreading drops .narrow(), calling .partial() also silently drops it.

Reproduction

import { type } from "arktype";

const User = type({ name: "string", email: "string" })
  .narrow((u) => u.email.includes("@"));

User({ name: "Yi", email: "bad" });   // ✗ rejected (correct)

const PatchUser = User.partial();
PatchUser({ email: "bad" });           // ✓ accepted — narrow is gone

Expected

Should either preserve the narrow or throw if it can't. As a quick fix, throwing when .partial() is applied to a narrowed/filtered schema would at least make the issue visible — similar to how Zod handles .partial() on refined schemas.

Environment

  • arktype 2.2.x
  • Node 22

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions