@@ -14,9 +14,11 @@ test('when creating a route with optional parameters', () => {
1414 routeTree : rootRoute . addChildren ( [ usersRoute ] ) ,
1515 } )
1616
17- expectTypeOf ( usersRoute . useParams < typeof router > ( ) ) . toEqualTypeOf < Accessor < {
18- tab ?: string
19- } > > ( )
17+ expectTypeOf ( usersRoute . useParams < typeof router > ( ) ) . toEqualTypeOf <
18+ Accessor < {
19+ tab ?: string
20+ } >
21+ > ( )
2022} )
2123
2224test ( 'when creating a route with mixed optional and required parameters' , ( ) => {
@@ -30,10 +32,12 @@ test('when creating a route with mixed optional and required parameters', () =>
3032 routeTree : rootRoute . addChildren ( [ usersRoute ] ) ,
3133 } )
3234
33- expectTypeOf ( usersRoute . useParams < typeof router > ( ) ) . toEqualTypeOf < Accessor < {
34- id : string
35- tab ?: string
36- } > > ( )
35+ expectTypeOf ( usersRoute . useParams < typeof router > ( ) ) . toEqualTypeOf <
36+ Accessor < {
37+ id : string
38+ tab ?: string
39+ } >
40+ > ( )
3741} )
3842
3943test ( 'when creating a route with optional param with prefix and suffix' , ( ) => {
@@ -47,9 +51,11 @@ test('when creating a route with optional param with prefix and suffix', () => {
4751 routeTree : rootRoute . addChildren ( [ filesRoute ] ) ,
4852 } )
4953
50- expectTypeOf ( filesRoute . useParams < typeof router > ( ) ) . toEqualTypeOf < Accessor < {
51- name ?: string
52- } > > ( )
54+ expectTypeOf ( filesRoute . useParams < typeof router > ( ) ) . toEqualTypeOf <
55+ Accessor < {
56+ name ?: string
57+ } >
58+ > ( )
5359} )
5460
5561test ( 'when creating Link with optional parameters' , ( ) => {
@@ -63,10 +69,12 @@ test('when creating Link with optional parameters', () => {
6369 routeTree : rootRoute . addChildren ( [ postsRoute ] ) ,
6470 } )
6571
66- expectTypeOf ( postsRoute . useParams < typeof router > ( ) ) . toEqualTypeOf < Accessor < {
67- category ?: string
68- slug ?: string
69- } > > ( )
72+ expectTypeOf ( postsRoute . useParams < typeof router > ( ) ) . toEqualTypeOf <
73+ Accessor < {
74+ category ?: string
75+ slug ?: string
76+ } >
77+ > ( )
7078} )
7179
7280test ( 'when using optional parameters in loaders' , ( ) => {
@@ -84,9 +92,11 @@ test('when using optional parameters in loaders', () => {
8492 routeTree : rootRoute . addChildren ( [ postsRoute ] ) ,
8593 } )
8694
87- expectTypeOf ( postsRoute . useLoaderData < typeof router > ( ) ) . toEqualTypeOf < Accessor < {
88- category ?: string
89- } > > ( )
95+ expectTypeOf ( postsRoute . useLoaderData < typeof router > ( ) ) . toEqualTypeOf <
96+ Accessor < {
97+ category ?: string
98+ } >
99+ > ( )
90100} )
91101
92102test ( 'when using optional parameters in beforeLoad' , ( ) => {
@@ -104,9 +114,11 @@ test('when using optional parameters in beforeLoad', () => {
104114 routeTree : rootRoute . addChildren ( [ postsRoute ] ) ,
105115 } )
106116
107- expectTypeOf ( postsRoute . useParams < typeof router > ( ) ) . toEqualTypeOf < Accessor < {
108- category ?: string
109- } > > ( )
117+ expectTypeOf ( postsRoute . useParams < typeof router > ( ) ) . toEqualTypeOf <
118+ Accessor < {
119+ category ?: string
120+ } >
121+ > ( )
110122} )
111123
112124test ( 'when using params.parse with optional parameters' , ( ) => {
@@ -134,9 +146,11 @@ test('when using params.parse with optional parameters', () => {
134146 } )
135147
136148 // Note: Type inference for params.parse is still complex - this represents current working behavior
137- expectTypeOf ( postsRoute . useParams < typeof router > ( ) ) . toMatchTypeOf < Accessor < {
138- page ?: number | undefined
139- } > > ( )
149+ expectTypeOf ( postsRoute . useParams < typeof router > ( ) ) . toMatchTypeOf <
150+ Accessor < {
151+ page ?: number | undefined
152+ } >
153+ > ( )
140154} )
141155
142156test ( 'when nesting routes with optional parameters' , ( ) => {
@@ -154,10 +168,12 @@ test('when nesting routes with optional parameters', () => {
154168 routeTree : rootRoute . addChildren ( [ postsRoute . addChildren ( [ postRoute ] ) ] ) ,
155169 } )
156170
157- expectTypeOf ( postRoute . useParams < typeof router > ( ) ) . toEqualTypeOf < Accessor < {
158- category ?: string
159- postId : string
160- } > > ( )
171+ expectTypeOf ( postRoute . useParams < typeof router > ( ) ) . toEqualTypeOf <
172+ Accessor < {
173+ category ?: string
174+ postId : string
175+ } >
176+ > ( )
161177} )
162178
163179test ( 'when combining optional parameters with wildcards' , ( ) => {
@@ -171,10 +187,12 @@ test('when combining optional parameters with wildcards', () => {
171187 routeTree : rootRoute . addChildren ( [ docsRoute ] ) ,
172188 } )
173189
174- expectTypeOf ( docsRoute . useParams < typeof router > ( ) ) . toEqualTypeOf < Accessor < {
175- version ?: string
176- _splat ?: string
177- } > > ( )
190+ expectTypeOf ( docsRoute . useParams < typeof router > ( ) ) . toEqualTypeOf <
191+ Accessor < {
192+ version ?: string
193+ _splat ?: string
194+ } >
195+ > ( )
178196} )
179197
180198test ( 'when using ResolveOptionalParams utility type' , ( ) => {
@@ -200,13 +218,15 @@ test('complex scenario with optional parameters only', () => {
200218 routeTree : rootRoute . addChildren ( [ complexRoute ] ) ,
201219 } )
202220
203- expectTypeOf ( complexRoute . useParams < typeof router > ( ) ) . toEqualTypeOf < Accessor < {
204- env ?: string
205- version ?: string
206- id : string
207- tab ?: string
208- _splat ?: string
209- } > > ( )
221+ expectTypeOf ( complexRoute . useParams < typeof router > ( ) ) . toEqualTypeOf <
222+ Accessor < {
223+ env ?: string
224+ version ?: string
225+ id : string
226+ tab ?: string
227+ _splat ?: string
228+ } >
229+ > ( )
210230} )
211231
212232test ( 'edge case - all optional parameters' , ( ) => {
@@ -220,9 +240,11 @@ test('edge case - all optional parameters', () => {
220240 routeTree : rootRoute . addChildren ( [ allOptionalRoute ] ) ,
221241 } )
222242
223- expectTypeOf ( allOptionalRoute . useParams < typeof router > ( ) ) . toEqualTypeOf < Accessor < {
224- category ?: string
225- subcategory ?: string
226- item ?: string
227- } > > ( )
243+ expectTypeOf ( allOptionalRoute . useParams < typeof router > ( ) ) . toEqualTypeOf <
244+ Accessor < {
245+ category ?: string
246+ subcategory ?: string
247+ item ?: string
248+ } >
249+ > ( )
228250} )
0 commit comments