@@ -246,6 +246,7 @@ const postgrest = new PostgrestClient<Database>(REST_URL)
246246 foo : number
247247 bar : { baz : number }
248248 en : 'ONE' | 'TWO' | 'THREE'
249+ record : Record < string , Json | undefined > | null
249250 qux : boolean
250251 }
251252 age_range : unknown
@@ -275,6 +276,7 @@ const postgrest = new PostgrestClient<Database>(REST_URL)
275276 foo : number
276277 bar : { baz : number }
277278 en : 'ONE' | 'TWO' | 'THREE'
279+ record : Record < string , Json | undefined > | null
278280 qux : boolean
279281 } | null
280282 age_range : unknown
@@ -342,6 +344,38 @@ const postgrest = new PostgrestClient<Database>(REST_URL)
342344 foo : string
343345 bar : { baz : number ; newBaz : string }
344346 en : 'FOUR' // Overridden enum value
347+ record : Record < string , Json | undefined > | null
348+ }
349+ age_range : unknown
350+ catchphrase : unknown
351+ status : 'ONLINE' | 'OFFLINE' | null
352+ } [ ]
353+ >
354+ > ( true )
355+ }
356+
357+ // Test merging with Json defined as Record
358+ {
359+ const result = await postgrest
360+ . from ( 'users' )
361+ . select ( )
362+ . overrideTypes < { data : { record : { baz : 'foo' } } } [ ] > ( )
363+ if ( result . error ) {
364+ throw new Error ( result . error . message )
365+ }
366+ let data : typeof result . data
367+ expectType <
368+ TypeEqual <
369+ typeof data ,
370+ {
371+ username : string
372+ data : {
373+ foo : string
374+ bar : {
375+ baz : number
376+ }
377+ en : 'ONE' | 'TWO' | 'THREE'
378+ record : { baz : 'foo' }
345379 }
346380 age_range : unknown
347381 catchphrase : unknown
@@ -504,29 +538,3 @@ const postgrest = new PostgrestClient<Database>(REST_URL)
504538 >
505539 > ( true )
506540}
507-
508- // Test overrideTypes array object with error embeded relation
509- {
510- const result = await postgrest . from ( 'users' ) . select ( '*, somerelation(*)' ) . overrideTypes <
511- {
512- somerelation : { created_at : Date ; data : string } [ ]
513- } [ ]
514- > ( )
515- if ( result . error ) {
516- throw new Error ( result . error . message )
517- }
518- let data : typeof result . data
519- expectType <
520- TypeEqual <
521- typeof data ,
522- {
523- username : string
524- data : CustomUserDataType | null
525- age_range : unknown
526- catchphrase : unknown
527- status : 'ONLINE' | 'OFFLINE' | null
528- somerelation : { created_at : Date ; data : string } [ ]
529- } [ ]
530- >
531- > ( true )
532- }
0 commit comments