Skip to content

fix: type pattern in configure (fixes #1469) - #1718

Open
SynthLuvr wants to merge 2 commits into
arktypeio:mainfrom
SynthLuvr:fix/1469-configure-pattern-typed
Open

SynthLuvr wants to merge 2 commits into
arktypeio:mainfrom
SynthLuvr:fix/1469-configure-pattern-typed

Conversation

@SynthLuvr

Copy link
Copy Markdown
Contributor

Fixes #1469

What

Users could pass pattern to .configure(...) and it was silently serialized into the generated JSON Schema, but the compiler rejected it since pattern was not part of the ambient meta type:

const T = type("string").configure({ pattern: "^$" }) // was a type error

Why

pattern is already copied verbatim from meta to the output schema by BaseRoot.toResolvedJsonSchema (meta keys that are valid JSON are spread onto the result), so the fix is purely type-level: add pattern?: string to NodeMeta in ark/schema/shared/declare.ts, from which ArkEnv.meta and TypeMeta are derived.

A JSDoc note documents the important gotcha that meta pattern does not affect validation— for that, use a regex definition like type("/^$/").

Tests

  • ark/type/__tests__/toJsonSchema.test.ts: asserts pattern is accepted by .configure (no type errors via attest(...).type.errors) and preserved by toJsonSchema() output.

Checks

  • Up-to-date with main (rebased on 326cdce)
  • pnpm prChecks passes locally (lint, build, typecheck, tests, benches — all instantiation benchmarks at 0.00% delta — as well as testTypedLoose, testTsCompat and testTsVersions)

pattern metadata was already serialized as the pattern keyword of
generated JSON Schema at runtime, but .configure() rejected it at
compile-time since it was missing from NodeMeta.

Add it to NodeMeta so it is accepted everywhere TypeMeta is, including
.configure(), the tuple "@" syntax and scope keywords configs.
- condense JSDoc for NodeMeta.pattern
- align test with repo conventions: bare issue-link comment,
  attest type.errors("") idiom for asserting no type errors
@github-project-automation github-project-automation Bot moved this to To do in arktypeio Oct 28, 2026
@SynthLuvr SynthLuvr changed the title fix: type in configure (fixes #1469) fix: type pattern in configure (fixes #1469) Oct 28, 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.

pattern in configure is not typed

1 participant