diff --git a/types/qs/index.d.ts b/types/qs/index.d.ts index fe11fe08bce0cd..5e1643f1192017 100644 --- a/types/qs/index.d.ts +++ b/types/qs/index.d.ts @@ -25,6 +25,7 @@ declare namespace QueryString { addQueryPrefix?: boolean | undefined; charset?: "utf-8" | "iso-8859-1" | undefined; charsetSentinel?: boolean | undefined; + allowEmptyArrays?: boolean | undefined; } type IStringifyDynamicOptions = AllowDots extends true diff --git a/types/qs/qs-tests.ts b/types/qs/qs-tests.ts index 3c09042b0cc972..919cdbbcfcd9f7 100644 --- a/types/qs/qs-tests.ts +++ b/types/qs/qs-tests.ts @@ -362,6 +362,11 @@ qs.parse("a=b&c=d", { delimiter: "&" }); assert.deepEqual(withEmptyArrays, { foo: [], bar: "baz" }); }); +(() => { + var withEmptyArrays = qs.stringify({ foo: [], bar: "baz" }, { allowEmptyArrays: true }); + assert.deepEqual(withEmptyArrays, "foo[]&bar=baz"); +}); + (() => { var withDots = qs.parse("name%252Eobj.first=John&name%252Eobj.last=Doe", { decodeDotInKeys: true }); assert.deepEqual(withDots, { "name.obj": { first: "John", last: "Doe" } });