refactor(v4): remove unnecessary type assertions#5720
refactor(v4): remove unnecessary type assertions#5720chisaki66 wants to merge 1 commit intocolinhacks:mainfrom
Conversation
There was a problem hiding this comment.
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.
|
Reviewed PR #5720. All 19
No issues found. Review submitted as COMMENT (no blocking concerns). |
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() callsparse.ts:Removed as any from parse, parseAsync, encode, decode, encodeAsync, decodeAsyncschemas.ts:Removed as any from string(), number(), boolean(), bigint(), array.element, and nativeEnum()