1+ import { Expand } from "../type_utils.js" ;
12import { GenericId } from "./index.js" ;
23import { GenericValidator , ObjectType } from "./validator.js" ;
34import { JSONValue , convexToJson } from "./value.js" ;
@@ -329,14 +330,14 @@ export class VObject<
329330 */
330331 omit < K extends keyof Fields & string > (
331332 ...fields : K [ ]
332- ) : VObject < Omit < Type , K > , Omit < Fields , K > , IsOptional > {
333+ ) : VObject < Expand < Omit < Type , K > > , Expand < Omit < Fields , K > > , IsOptional > {
333334 const newFields = { ...this . fields } ;
334335 for ( const field of fields ) {
335336 delete newFields [ field ] ;
336337 }
337338 return new VObject ( {
338339 isOptional : this . isOptional ,
339- fields : newFields as Omit < Fields , K > ,
340+ fields : newFields as any ,
340341 } ) ;
341342 }
342343
@@ -346,14 +347,18 @@ export class VObject<
346347 */
347348 pick < K extends keyof Fields & string > (
348349 ...fields : K [ ]
349- ) : VObject < Pick < Type , Extract < keyof Type , K > > , Pick < Fields , K > , IsOptional > {
350+ ) : VObject <
351+ Expand < Pick < Type , Extract < keyof Type , K > > > ,
352+ Expand < Pick < Fields , K > > ,
353+ IsOptional
354+ > {
350355 const newFields : Record < string , GenericValidator > = { } ;
351356 for ( const field of fields ) {
352357 newFields [ field ] = this . fields [ field ] ;
353358 }
354359 return new VObject ( {
355360 isOptional : this . isOptional ,
356- fields : newFields as Pick < Fields , K > ,
361+ fields : newFields as Expand < Pick < Fields , K > > ,
357362 } ) ;
358363 }
359364
@@ -383,10 +388,14 @@ export class VObject<
383388 */
384389 extend < NewFields extends Record < string , GenericValidator > > (
385390 fields : NewFields ,
386- ) : VObject < Type & ObjectType < NewFields > , Fields & NewFields , IsOptional > {
391+ ) : VObject <
392+ Expand < Type & ObjectType < NewFields > > ,
393+ Expand < Fields & NewFields > ,
394+ IsOptional
395+ > {
387396 return new VObject ( {
388397 isOptional : this . isOptional ,
389- fields : { ...this . fields , ...fields } as Fields & NewFields ,
398+ fields : { ...this . fields , ...fields } as Expand < Fields & NewFields > ,
390399 } ) ;
391400 }
392401}
0 commit comments