File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -339,11 +339,18 @@ export interface StringifyOptions {
339339 readonly skipEmptyString ?: boolean ;
340340}
341341
342+ export type Stringifiable = string | boolean | number ;
343+
344+ export type StringifiableRecord = Record <
345+ string ,
346+ Stringifiable | Stringifiable [ ] | null | undefined
347+ > ;
348+
342349/**
343350Stringify an object into a query string and sort the keys.
344351*/
345352export function stringify (
346- object : { [ key : string ] : any } ,
353+ object : StringifiableRecord ,
347354 options ?: StringifyOptions
348355) : string ;
349356
@@ -358,9 +365,9 @@ export interface UrlObject {
358365 readonly url : string ;
359366
360367 /**
361- Qverrides queries in the `url` property.
368+ Overrides queries in the `url` property.
362369 */
363- readonly query : Record < string , string | undefined | null > ;
370+ readonly query : StringifiableRecord ;
364371
365372 /**
366373 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>(
9494// Extract
9595expectType < string > ( queryString . extract ( 'http://foo.bar/?abc=def&hij=klm' ) ) ;
9696
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