Skip to content

toJsonSchema({ useRefs: true }) fails for partially overlapping discriminated union #1511

Closed

Description

@eyalkutz

Report a bug

🔎 Search Terms

toJsonSchema

🧩 Context

  • ArkType version: 2.1.22
  • TypeScript version (5.1+): bun version 1.2.8, also reproduced in node v22.15.1 without typescript
  • Other context you think may be relevant (JS flavor, OS, etc.):

🧑‍💻 Repro

Playground Link: https://arktype.io/playground?code=import%2520%257Btype%257D%2520from%2520%27arktype%27%253B%250A%250Atype%250A%2520%2520.or%28%250A%2520%2520%2520%2520%257B%250A%2520%2520%2520%2520%2520%2520a%253A%2520type.enumerated%28%2522a%2522%252C%2520%2522b%2522%252C%2520%2522c%2522%29%252C%250A%2520%2520%2520%2520%2520%2520b%253A%2520%271%27%252C%250A%2520%2520%2520%2520%257D%252C%250A%2520%2520%2520%2520%257B%250A%2520%2520%2520%2520%2520%2520a%253A%2520type.enumerated%28%2522a%2522%252C%2520%2522e%2522%252C%2520%2522f%2522%29%252C%250A%2520%2520%2520%2520%2520%2520b%253A%2520%272%27%252C%250A%2520%2520%2520%2520%257D%250A%2520%2520%29%250A%2520%2520.toJsonSchema%28%257B%2520useRefs%253A%2520true%2520%257D%29%253B

import {type} from 'arktype';

type
  .or(
    {
      a: type.enumerated("a", "b", "c"),
      b: '1',
    },
    {
      a: type.enumerated("a", "e", "f"),
      b: '2',
    }
  )
  .toJsonSchema({ useRefs: true });

note that this code does run without errors if { useRefs: false }

Activity

  1. added a commit that references this issue on Oct 20, 2026
    2503852
  2. moved this from To do to Done (merged or closed) in arktypeioon Oct 20, 2026
  3. added a commit that references this issue on Oct 26, 2026
    fc06904
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

  • Status
    Done (merged or closed)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions