Skip to content

Commit

Permalink
Fix the ParsedQuery TypeScript typ
Browse files Browse the repository at this point in the history
Fixes #273
  • Loading branch information
sindresorhus committed Sep 13, 2020
1 parent f38dab5 commit 56d2923
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Expand Up @@ -121,7 +121,7 @@ export interface ParseOptions {
```
*/
readonly parseBooleans?: boolean;

/**
Parse the fragment identifier from the URL and add it to result object.
Expand All @@ -139,7 +139,7 @@ export interface ParseOptions {
}

export interface ParsedQuery<T = string> {
[key: string]: T | T[] | null | undefined;
[key: string]: T | T[] | null;
}

/**
Expand Down

4 comments on commit 56d2923

@krtrice
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sindresorhus In your readme file, undefined is described as the means of removing a param from a URL. Since this is a breaking change that no longer supports this use case for typescript users, I would suggest removing references to undefined from your docs.

@sindresorhus
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is about the return value for parsing, not stringifying.

@krtrice
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing https://github.com/sindresorhus/query-string/blob/master/index.d.ts, the ParsedQuery interface is being used in the stringifyUrl() parameter types in addition to the parse() return types.

// line 141
export interface ParsedQuery<T = string> {
	[key: string]: T | T[] | null;
}

// line 157
export interface ParsedUrl {
	readonly url: string;
	readonly query: ParsedQuery;

	/**
	The fragment identifier of the URL.
	Present when the `parseFragmentIdentifier` option is `true`.
	*/
	readonly fragmentIdentifier?: string;
}

// line 382
export function stringifyUrl(
	object: ParsedUrl,
	options?: StringifyOptions
): string;

@sindresorhus
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.