Skip to content

Fully discriminate literal unions nested in properties #1491

Closed

Description

@felixSchl

🔎 Search Terms

unions, discrimination, discriminate, discriminant, literals, strings, nested, properties

🧩 Context

  • ArkType version: 2.1.20
  • TypeScript version (5.1+): 5.7
  • Other context you think may be relevant (JS flavor, OS, etc.): -
  System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 80.00 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.17.0 - ~/.nvm/versions/node/v22.17.0/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v22.17.0/bin/npm
    pnpm: 9.13.2 - ~/Library/pnpm/pnpm
    bun: 1.2.17 - ~/.bun/bin/bun
  npmPackages:
    typescript: catalog: => 5.7.3

🧑‍💻 Repro

Nested union playground: https://arktype.io/playground?code=import%2520%257B%2520type%2520%257D%2520from%2520%2522arktype%2522%250A%250Aconst%2520Thing%2520%253D%2520type%28%257B%250A%2509tag%253A%2520%27%2522a%2522%27%252C%250A%2520%2520%2520%2520a%253A%2520%27number%27%250A%257D%29.or%28%257B%250A%2520%2520%2520%2520tag%253A%2520%27%2522b%2522%2520%257C%2520%2522c%2522%27%252C%250A%2520%2520%2520%2520bc%253A%2520%27string%27%250A%257D%29%250A%250Aconst%2520out%2520%253D%2520Thing%28%257B%250A%257D%29%250A

Fully discriminated playground: https://arktype.io/playground?code=import%2520%257B%2520type%2520%257D%2520from%2520%2522arktype%2522%250A%250Aconst%2520Thing%2520%253D%2520type%28%257B%250A%2509tag%253A%2520%27%2522a%2522%27%252C%250A%2520%2520%2520%2520a%253A%2520%27number%27%250A%257D%29.or%28%257B%250A%2520%2520%2520%2520tag%253A%2520%27%2522b%2522%27%252C%250A%2520%2520%2520%2520bc%253A%2520%27string%27%250A%257D%29.or%28%257B%250A%2520%2520%2520%2520tag%253A%2520%27%2522c%2522%27%252C%250A%2520%2520%2520%2520bc%253A%2520%27string%27%250A%257D%29%250A%250Aconst%2520out%2520%253D%2520Thing%28%257B%250A%257D%29%250A

The error output is inconsistent. When the form '"b" | "c"' is used it doesn't tell me the discriminator "tag" is absent.


Discussion on Discord: https://discordapp.com/channels/957797212103016458/957804102685982740/1406737917430206564

Activity

  1. added
    enhancementNew feature or request
    confirmedThe maintainers of the repo would like to address this
    and removed
    bugSomething isn't working
    on Aug 19, 2025
  2. changed the title [-]Inconsistent error handling around unions[/-] [+]Fully discriminate literal unions nested in properties[/+] on Aug 19, 2025
  3. ssalbdivad commented on Nov 18, 2026

    @ssalbdivad
    Member

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

  4. 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

Labels

confirmedThe maintainers of the repo would like to address thisenhancementNew feature or request

Type

No type

Projects

  • Status
    Done (merged or closed)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions