Skip to content

refactor(schema): align array overload structure#49

Merged
SrHenry merged 2 commits into
developerfrom
refactor/p2-type-inference-improvements
May 27, 2026
Merged

refactor(schema): align array overload structure#49
SrHenry merged 2 commits into
developerfrom
refactor/p2-type-inference-improvements

Conversation

@SrHenry

@SrHenry SrHenry commented May 27, 2026

Copy link
Copy Markdown
Owner

Summary

Merges the split ValidatorMap<T> and TypeGuard<T> | StandardSchemaV1<T, T> overloads in _fn and OptionalizedArray into a single combined overload, matching the structure already used in ArraySchema.

Changes

  • src/validators/schema/array.ts: merged _fn overloads (2 → 1), merged OptionalizedArray overloads (2 → 1), reordered (tree: {}) last
  • src/validators/schema/types/ArraySchema.ts: reordered (tree: {}) last (already done in fix(schema): preserve array element inference #46, included here for completeness)
  • src/validators/__tests__/array.spec.ts: type inference + runtime tests (13 tests)

Verification

  • All 377 tests pass
  • Typecheck clean
  • No circular dependencies
  • Lint/format clean

Related

Merge ValidatorMap<T> and TypeGuard<T> | StandardSchemaV1<T, T> into
a single overload signature in _fn and OptionalizedArray, matching the
structure already used in ArraySchema. Reduces overload count and
eliminates structural divergence between type and implementation.

Also reorder (tree: {}) fallback to last position (per #46) and add
array type inference + runtime tests.

Closes #47
@SrHenry SrHenry marked this pull request as ready for review May 27, 2026 17:22
@SrHenry

SrHenry commented May 27, 2026

Copy link
Copy Markdown
Owner Author

Review notes (low severity)

  1. Merged overload — structurally ambiguous inputs: Merging ValidatorMap<T> | TypeGuard<T> | StandardSchemaV1<T, T> into a single overload means TypeScript infers T from a union type rather than independently per overload. If a value is simultaneously callable and has a ValidatorMap-like shape (e.g., a callable object with validator properties), the merged form could infer a wider T than the split overloads would. In practice, TypeGuard (function) and ValidatorMap (plain object record) are structurally disjoint, so this is unlikely to matter.

  2. No test for callable-object edge case: A test passing a callable ValidatorMap-like object would explicitly confirm the merge does not change inference behavior for ambiguous inputs. Risk is low given the structural disjointness, but worth noting for completeness.

@SrHenry SrHenry merged commit fcca68c into developer May 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(schema): align _fn/OptionalizedArray overload structure with ArraySchema

1 participant