Skip to content

Commit d5f0810

Browse files
🤖 Merge PR DefinitelyTyped#74642 [@types/qs]: add strictMerge option to IParseBaseOptions by @kshitijanurag
1 parent fec398a commit d5f0810

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎types/qs/index.d.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ declare namespace QueryString {
5858
allowEmptyArrays?: boolean | undefined;
5959
duplicates?: "combine" | "first" | "last" | undefined;
6060
strictDepth?: boolean | undefined;
61+
strictMerge?: boolean | undefined;
6162
throwOnLimitExceeded?: boolean | undefined;
6263
}
6364

‎types/qs/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@types/qs",
4-
"version": "6.14.9999",
4+
"version": "6.15.9999",
55
"projects": [
66
"https://github.com/ljharb/qs"
77
],

‎types/qs/qs-tests.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,40 @@ qs.parse("a=b&c=d", { delimiter: "&" });
426426
);
427427
});
428428

429+
(() => {
430+
assert.deepEqual(
431+
qs.parse("a[b]=c&a=d", { strictMerge: false }),
432+
{ a: { b: "c", d: true } },
433+
);
434+
435+
assert.deepEqual(
436+
qs.parse("a[b]=c&a=toString", { strictMerge: false }),
437+
{ a: { b: "c" } },
438+
);
439+
440+
assert.deepEqual(
441+
qs.parse("a[b]=c&a=toString", { strictMerge: false, allowPrototypes: true }),
442+
{ a: { b: "c", toString: true } },
443+
);
444+
});
445+
446+
(() => {
447+
assert.deepEqual(
448+
qs.parse("a[b]=c&a=d"),
449+
{ a: [{ b: "c" }, "d"] },
450+
);
451+
452+
assert.deepEqual(
453+
qs.parse("a=d&a[b]=c"),
454+
{ a: ["d", { b: "c" }] },
455+
);
456+
457+
assert.deepEqual(
458+
qs.parse("a[b]=c&a=toString"),
459+
{ a: [{ b: "c" }, "toString"] },
460+
);
461+
});
462+
429463
declare const myQuery: { a: string; b?: string | undefined };
430464
const myQueryCopy: qs.ParsedQs = myQuery;
431465

0 commit comments

Comments
 (0)