File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -168,26 +168,29 @@ interface Router {
168
168
*/
169
169
// Called with no arguments - returns a Router instance
170
170
export function route ( ) : Router ;
171
+
172
+ // Called with configuration arguments only - returns a configured Router instance
173
+ export function route (
174
+ name : undefined ,
175
+ params : undefined ,
176
+ absolute ?: boolean ,
177
+ config ?: Config ,
178
+ ) : Router ;
179
+
171
180
// Called with a route name and optional additional arguments - returns a URL string
172
181
export function route < T extends RouteName > (
173
182
name : T ,
174
183
params ?: RouteParams < T > | undefined ,
175
184
absolute ?: boolean ,
176
185
config ?: Config ,
177
186
) : string ;
187
+
178
188
export function route < T extends RouteName > (
179
189
name : T ,
180
190
params ?: ParameterValue | undefined ,
181
191
absolute ?: boolean ,
182
192
config ?: Config ,
183
193
) : string ;
184
- // Called with configuration arguments only - returns a configured Router instance
185
- export function route (
186
- name : undefined ,
187
- params : undefined ,
188
- absolute ?: boolean ,
189
- config ?: Config ,
190
- ) : Router ;
191
194
192
195
/**
193
196
* Ziggy's Vue plugin.
Original file line number Diff line number Diff line change 1
1
import { assertType } from 'vitest' ;
2
- import { route } from '../../src/js' ;
2
+ import { Config , route , Router } from '../../src/js' ;
3
3
4
4
// Add generated routes to use for testing inside this file. In a real app these declarations
5
5
// would be in a separate file generated by running `php artisan ziggy:generate --types`.
@@ -97,3 +97,8 @@ assertType(route().current('posts.comments.show', { post: 2 }));
97
97
assertType ( route ( ) . current ( 'posts.comments.show' , 2 ) ) ;
98
98
// assertType(route().current('posts.comments.show', [2])); // TODO shouldn't error, only one required param
99
99
assertType ( route ( ) . current ( 'posts.comments.show' , 'foo' ) ) ;
100
+
101
+ // Test route function return types
102
+ assertType < string > ( route ( 'optional' , { maybe : 'foo' } ) ) ;
103
+ assertType < string > ( route ( 'optional' , 'foo' ) ) ;
104
+ assertType < Router > ( route ( undefined , undefined , undefined , { } as Config ) ) ;
You can’t perform that action at this time.
0 commit comments