Skip to content

Commit

Permalink
Fix the TypeScript type for the .stringifyUrl() method
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Sep 27, 2020
1 parent 60802a7 commit b15f945
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion index.d.ts
Expand Up @@ -354,6 +354,20 @@ Note: This behaviour can be changed with the `skipNull` option.
*/
export function extract(url: string): string;

export interface UrlObject {
readonly url: string;

/**
Qverrides queries in the `url` property.
*/
readonly query: Record<string, string | undefined | null>;

/**
Overrides the fragment identifier in the `url` property.
*/
readonly fragmentIdentifier?: string;
}

/**
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)
Expand All @@ -380,6 +394,6 @@ queryString.stringifyUrl({
```
*/
export function stringifyUrl(
object: ParsedUrl,
object: UrlObject,
options?: StringifyOptions
): string;
2 changes: 2 additions & 0 deletions index.test-d.ts
Expand Up @@ -93,3 +93,5 @@ expectType<queryString.ParsedUrl>(

// Extract
expectType<string>(queryString.extract('http://foo.bar/?abc=def&hij=klm'));

expectType<string>(queryString.stringifyUrl({url: 'https://sindresorhus.com', query: {foo: undefined}}));

0 comments on commit b15f945

Please sign in to comment.