Skip to content

Discrimination with optional never #1543

Closed

Description

@ssalbdivad

Currently the following gives a ParseError Default for never:

import { type } from "arktype";

const Expired = type({
  bookingCode: "string",
  passengers: [
    {
      status: '"REJECTED"',
      reason: '"timeout"',
    },
  ],
  registrationStatus: '"EXPIRED" = "EXPIRED"',
});

const Rejected = type({
  "bookingCode?": "never",
  passengers: [
    {
      status: '"REJECTED"',
      reason: "string",
    },
  ],
  registrationStatus: '"REJECTED" = "REJECTED"',
});

const Thing = Expired.or(Rejected);

const out = Thing({
  bookingCode: "abc",
  passengers: [
    {
      status: "REJECTED",
      reason: "timeout",
    },
  ],
});

This union should be allowed

Activity

  1. ssalbdivad commented on Nov 18, 2026

    @ssalbdivad
    MemberAuthor

    Fixed in 3.0.0-beta.0 (#1728). Try it with npm i arktype@next.

  2. moved this from To do to Done (merged or closed) in arktypeioon Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Done (merged or closed)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions