File tree 2 files changed +26
-4
lines changed
2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -339,11 +339,18 @@ export interface StringifyOptions {
339
339
readonly skipEmptyString ?: boolean ;
340
340
}
341
341
342
+ export type Stringifiable = string | boolean | number ;
343
+
344
+ export type StringifiableRecord = Record <
345
+ string ,
346
+ Stringifiable | Stringifiable [ ] | null | undefined
347
+ > ;
348
+
342
349
/**
343
350
Stringify an object into a query string and sort the keys.
344
351
*/
345
352
export function stringify (
346
- object : { [ key : string ] : any } ,
353
+ object : StringifiableRecord ,
347
354
options ?: StringifyOptions
348
355
) : string ;
349
356
@@ -358,9 +365,9 @@ export interface UrlObject {
358
365
readonly url : string ;
359
366
360
367
/**
361
- Qverrides queries in the `url` property.
368
+ Overrides queries in the `url` property.
362
369
*/
363
- readonly query : Record < string , string | undefined | null > ;
370
+ readonly query : StringifiableRecord ;
364
371
365
372
/**
366
373
Overrides the fragment identifier in the `url` property.
Original file line number Diff line number Diff line change @@ -94,4 +94,19 @@ expectType<queryString.ParsedUrl>(
94
94
// Extract
95
95
expectType < string > ( queryString . extract ( 'http://foo.bar/?abc=def&hij=klm' ) ) ;
96
96
97
- expectType < string > ( queryString . stringifyUrl ( { url : 'https://sindresorhus.com' , query : { foo : undefined } } ) ) ;
97
+ expectType < string > (
98
+ queryString . stringifyUrl ( {
99
+ url : 'https://sindresorhus.com' ,
100
+ query : {
101
+ fooArray : [
102
+ 'a' ,
103
+ 'b'
104
+ ] ,
105
+ fooNumber : 1 ,
106
+ fooBoolean : true ,
107
+ fooNull : null ,
108
+ fooUndefined : undefined ,
109
+ fooString : 'hi'
110
+ } ,
111
+ } )
112
+ ) ;
You can’t perform that action at this time.
0 commit comments