File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -17,17 +17,28 @@ import {
1717} from './arg-metadata' ;
1818
1919function unwrapType ( type : unknown ) : z . ZodType {
20- if ( type instanceof z . ZodOptional || type instanceof z . ZodDefault ) {
21- return unwrapType ( type . unwrap ( ) ) ;
20+ assertZodType ( type ) ;
21+ let unwrappedType = z . clone ( type ) ;
22+ while (
23+ unwrappedType instanceof z . ZodOptional ||
24+ unwrappedType instanceof z . ZodDefault
25+ ) {
26+ const nextWrap = unwrappedType . unwrap ( ) ;
27+ assertZodType ( nextWrap ) ;
28+ unwrappedType = nextWrap ;
2229 }
30+
31+ return type ;
32+ }
33+
34+ function assertZodType ( type : unknown ) : asserts type is z . ZodType {
2335 if ( ! ( type instanceof z . ZodType ) ) {
2436 throw new Error (
2537 `Unknown schema field type: ${
2638 type && typeof type === 'object' ? type . constructor . name : typeof type
2739 } `
2840 ) ;
2941 }
30- return type ;
3142}
3243
3344export const defaultParserOptions : Partial < YargsOptions > = {
You can’t perform that action at this time.
0 commit comments