File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -79,13 +79,13 @@ export function generateType(schema: Schema, options?: Options): TypeNode {
7979 }
8080
8181 let valids : TypeNode [ ] = Array . from ( ( schema as ExtendedSchema ) . _valids ?. _values ?? new Set ( ) ) . map ( ( value ) => {
82- // unknown | null is redundant, so just drop the null
83- if ( schema . type === "any" && value === null ) {
82+ // unknown | null is redundant, so just drop the null unless this is the only allowed value
83+ if ( schema . _flags . only !== true && schema . type === "any" && value === null ) {
8484 return ;
8585 }
8686
8787 // string | "" is redundant, so just drop the ""
88- if ( schema . type === "string" && value === "" ) {
88+ if ( schema . _flags . only !== true && schema . type === "string" && value === "" ) {
8989 return ;
9090 }
9191
You can’t perform that action at this time.
0 commit comments