From 49029887d440ca94fbe4fff724d3ec121bd16109 Mon Sep 17 00:00:00 2001 From: bug-brain <40305896+bug-brain@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:16:17 +0100 Subject: [PATCH] recognize bigint as stringifiable --- base.d.ts | 2 +- test/stringify.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/base.d.ts b/base.d.ts index 0803e2a..f6bbd9a 100644 --- a/base.d.ts +++ b/base.d.ts @@ -412,7 +412,7 @@ export type StringifyOptions = { readonly skipEmptyString?: boolean; }; -export type Stringifiable = string | boolean | number | null | undefined; // eslint-disable-line @typescript-eslint/ban-types +export type Stringifiable = string | boolean | number | bigint | null | undefined; // eslint-disable-line @typescript-eslint/ban-types export type StringifiableRecord = Record< string, diff --git a/test/stringify.js b/test/stringify.js index d68f097..eae6271 100644 --- a/test/stringify.js +++ b/test/stringify.js @@ -14,6 +14,13 @@ test('different types', t => { t.is(queryString.stringify(0), ''); }); +test('primitive types', t => { + t.is(queryString.stringify({ a: "string" }), "a=string") + t.is(queryString.stringify({ a: true, b: false }), "a=true&b=false") + t.is(queryString.stringify({ a: 0, b: 1n }), "a=0&b=1") + t.is(queryString.stringify({a: null, b: undefined}), "a") +}) + test('URI encode', t => { t.is(queryString.stringify({'foo bar': 'baz faz'}), 'foo%20bar=baz%20faz'); t.is(queryString.stringify({'foo bar': 'baz\'faz'}), 'foo%20bar=baz%27faz');