Skip to content

Commit b15f945

Browse files
committedSep 27, 2020
Fix the TypeScript type for the .stringifyUrl() method
1 parent 60802a7 commit b15f945

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
 

‎index.d.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,20 @@ Note: This behaviour can be changed with the `skipNull` option.
354354
*/
355355
export function extract(url: string): string;
356356

357+
export interface UrlObject {
358+
readonly url: string;
359+
360+
/**
361+
Qverrides queries in the `url` property.
362+
*/
363+
readonly query: Record<string, string | undefined | null>;
364+
365+
/**
366+
Overrides the fragment identifier in the `url` property.
367+
*/
368+
readonly fragmentIdentifier?: string;
369+
}
370+
357371
/**
358372
Stringify an object into a URL with a query string and sorting the keys. The inverse of [`.parseUrl()`](https://github.com/sindresorhus/query-string#parseurlstring-options)
359373
@@ -380,6 +394,6 @@ queryString.stringifyUrl({
380394
```
381395
*/
382396
export function stringifyUrl(
383-
object: ParsedUrl,
397+
object: UrlObject,
384398
options?: StringifyOptions
385399
): string;

‎index.test-d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,5 @@ expectType<queryString.ParsedUrl>(
9393

9494
// Extract
9595
expectType<string>(queryString.extract('http://foo.bar/?abc=def&hij=klm'));
96+
97+
expectType<string>(queryString.stringifyUrl({url: 'https://sindresorhus.com', query: {foo: undefined}}));

0 commit comments

Comments
 (0)
Please sign in to comment.