Skip to content

refactor(v4): remove unnecessary type assertions#5720

Open
chisaki66 wants to merge 1 commit intocolinhacks:mainfrom
chisaki66:refactor/remove-unnecessary-type-assertions
Open

refactor(v4): remove unnecessary type assertions#5720
chisaki66 wants to merge 1 commit intocolinhacks:mainfrom
chisaki66:refactor/remove-unnecessary-type-assertions

Conversation

@chisaki66
Copy link

Removes as any type assertions to improve type safety and leverage TypeScript's type inference.

Changes

from-json-schema.ts: Removed as any from array/tuple constraint methods and default() calls
parse.ts: Removed as any from parse, parseAsync, encode, decode, encodeAsync, decodeAsync
schemas.ts: Removed as any from string(), number(), boolean(), bigint(), array.element, and nativeEnum()

Copy link
Contributor

@pullfrog pullfrog bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build and all 1982 tests pass cleanly (including type checks). Every as any removal is verified type-safe: the core factory functions (_string, _number, _boolean, _bigint) use generics that infer the correct return type from the class argument, the _parse/_encode/_decode family return types already match the declared signatures exactly, and the nativeEnum single cast works because ZodEnum (unbound default) is structurally compatible with ZodEnum<T>. Good cleanup.

Pullfrog  | View workflow runpullfrog.com𝕏

@pullfrog
Copy link
Contributor

pullfrog bot commented Feb 15, 2026

Reviewed PR #5720. All 19 as any removals are verified type-safe:

  • Build: passes cleanly
  • Tests: all 1982 tests pass (including type checks across 148 files)
  • Type analysis: each removal was investigated — the core factory functions, parse helpers, and array element assignment all have types that already align without casts

No issues found. Review submitted as COMMENT (no blocking concerns).

Pullfrog  | View workflow run | Using Claude Code | Triggered by Pullfrogpullfrog.com𝕏

@chisaki66 chisaki66 changed the title Remove unnecessary as any type assertions refactor(v4): remove unnecessary type assertions Feb 15, 2026
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.

1 participant