Skip to content

Commit

Permalink
Work around TypeScript bug
Browse files Browse the repository at this point in the history
Fixes #298
  • Loading branch information
sindresorhus committed Dec 30, 2020
1 parent 35846d9 commit 94ebcd4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.d.ts
Expand Up @@ -350,7 +350,12 @@ export type StringifiableRecord = Record<
Stringify an object into a query string and sort the keys.
*/
export function stringify(
object: StringifiableRecord,
// TODO: Use the below instead when the following TS issues are fixed:
// - https://github.com/microsoft/TypeScript/issues/15300
// - https://github.com/microsoft/TypeScript/issues/42021
// Context: https://github.com/sindresorhus/query-string/issues/298
// object: StringifiableRecord,
object: Record<string, any>,
options?: StringifyOptions
): string;

Expand Down
11 changes: 11 additions & 0 deletions index.test-d.ts
Expand Up @@ -35,6 +35,17 @@ expectType<string>(
)
);

// Ensure it accepts an `interface`.
interface Query {
foo: string;
}

const query: Query = {
foo: 'bar'
};

queryString.stringify(query);

// Parse
expectType<queryString.ParsedQuery>(queryString.parse('?foo=bar'));

Expand Down

0 comments on commit 94ebcd4

Please sign in to comment.