Skip to content

test: cover undefined discriminant cases on a nested path - #1725

Open
RClaudiuM wants to merge 1 commit into
arktypeio:mainfrom
RClaudiuM:fix/1724-undefined-discriminant-primitive
Open

RClaudiuM wants to merge 1 commit into
arktypeio:mainfrom
RClaudiuM:fix/1724-undefined-discriminant-primitive

Conversation

@RClaudiuM

@RClaudiuM RClaudiuM commented Nov 7, 2026 •

Copy link
Copy Markdown

Refs #1724

Update

The fix for #1724 landed on main with the union rewrite (thanks for the credit in the changelog). I merged main, dropped the source change since ark/sets/roots/union.ts already handles it, and kept the regression tests, so this PR is now test-only.

Tests

In ark/type/__tests__/discrimination.test.ts, each with JIT and jitless: true where it applies:

  • the example from the issue ({ k: "1", a: "2" } | { k: "3", a: "undefined" }) rejects 0, "s", null and undefined with "must be an object", and still checks k
  • { a: 2 } | { a: undefined } rejects 0 and {} and accepts { a: undefined }, also for a two-level path ({ a: { b: ... } })
  • a domain discriminant with an undefined case ({ a: string, b: 1 } | { a: undefined } | { a: number, b: 2 }) rejects primitives and {} and still checks b in the other branches

They pass on current main, and the first one throws the TypeError from the issue on 2.x.

Checks run locally: pnpm testCore (3300 passing), pnpm testFiles ark/type/__tests__/discrimination.test.ts, pnpm typecheckRepo, prettier and eslint on the test file.

  • Code is up-to-date with the main branch
  • There are new or updated unit tests validating the change

@github-project-automation github-project-automation Bot moved this to To do in arktypeio Nov 7, 2026
ssalbdivad added a commit that referenced this pull request Nov 9, 2026
…uthors

Each fix below landed on featherduster from a port or an independent fix,
but each started from a reasonable community PR against 2.x, and the
CHANGELOG thanks every contributor whose work this release supersedes:

- #1721 (@RaphaelFakhri): fast-check keeps a regex's flags (#1720)
- #1722 (@louisss1016): Temporal values survive a morph / deepClone (#1719)
- #1725 (@RClaudiuM): an undefined discriminant case checks its key (#1724)
- #1715 (@SynthLuvr): ~standard.jsonSchema.input drops undefined (#1462);
  only its input half was taken, output keeps routing to fallback.unit

#1718 is not credited: 3.0 answers #1469 with jsonSchema meta rather than
its bare pattern key. #1705 and #1695 were already thanked.

Also notes that a cyclic index signature with no way out now generates
shrinking dictionaries instead of overflowing the stack (6f4dd5d).
@ssalbdivad ssalbdivad mentioned this pull request Nov 9, 2026
Unions discriminated on a nested path with an undefined case must keep
the object and key checks for that case, since data?.a is also
undefined for primitives and objects without the key (arktypeio#1724).
@RClaudiuM
RClaudiuM force-pushed the fix/1724-undefined-discriminant-primitive branch from 785070c to 96c75a5 Compare November 18, 2026 08:21
@RClaudiuM RClaudiuM changed the title fix(schema): keep object checks for an undefined case on a nested path test: cover undefined discriminant cases on a nested path Nov 18, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To do

Development

Successfully merging this pull request may close these issues.

1 participant