Skip to content

Commit 94ebcd4

Browse files
committedDec 30, 2020
Work around TypeScript bug
Fixes #298
1 parent 35846d9 commit 94ebcd4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
 

‎index.d.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,12 @@ export type StringifiableRecord = Record<
350350
Stringify an object into a query string and sort the keys.
351351
*/
352352
export function stringify(
353-
object: StringifiableRecord,
353+
// TODO: Use the below instead when the following TS issues are fixed:
354+
// - https://github.com/microsoft/TypeScript/issues/15300
355+
// - https://github.com/microsoft/TypeScript/issues/42021
356+
// Context: https://github.com/sindresorhus/query-string/issues/298
357+
// object: StringifiableRecord,
358+
object: Record<string, any>,
354359
options?: StringifyOptions
355360
): string;
356361

‎index.test-d.ts

+11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ expectType<string>(
3535
)
3636
);
3737

38+
// Ensure it accepts an `interface`.
39+
interface Query {
40+
foo: string;
41+
}
42+
43+
const query: Query = {
44+
foo: 'bar'
45+
};
46+
47+
queryString.stringify(query);
48+
3849
// Parse
3950
expectType<queryString.ParsedQuery>(queryString.parse('?foo=bar'));
4051

0 commit comments

Comments
 (0)
Please sign in to comment.