File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ describe('QueryFilters', () => {
5050 expectTypeOf ( filters . queryKey ) . toEqualTypeOf <
5151 | undefined
5252 | readonly [ ]
53- | [ 'key' ]
53+ | readonly [ 'key' ]
5454 | readonly [
5555 'key' ,
5656 {
@@ -61,6 +61,18 @@ describe('QueryFilters', () => {
6161 > ( )
6262 } )
6363
64+ it ( 'should work with readonly union types' , ( ) => {
65+ const filters : QueryFilters <
66+ readonly [ 'key' ] | readonly [ 'key' , 'something' ]
67+ > = {
68+ queryKey : [ 'key' ] ,
69+ }
70+
71+ expectTypeOf ( filters . queryKey ) . toEqualTypeOf <
72+ undefined | readonly [ ] | readonly [ 'key' ] | readonly [ 'key' , 'something' ]
73+ > ( )
74+ } )
75+
6476 it ( 'should error on invalid query keys' , ( ) => {
6577 assertType < QueryFilters < readonly [ 'key' , { a : number ; b : string } ] > > ( {
6678 // @ts -expect-error cannot pass invalid query key
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ type DropLast<T extends ReadonlyArray<unknown>> = T extends readonly [
2020 ...infer R ,
2121 unknown ,
2222]
23- ? R
23+ ? readonly [ ... R ]
2424 : never
2525
2626type TuplePrefixes < T extends ReadonlyArray < unknown > > = T extends readonly [ ]
You can’t perform that action at this time.
0 commit comments