Skip to content

Commit ca30a75

Browse files
committed
fix(types): allow null/undefined in query params
fix #2605
1 parent 658eee6 commit ca30a75

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

types/router.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export interface Location {
108108
name?: string;
109109
path?: string;
110110
hash?: string;
111-
query?: Dictionary<string | string[]>;
111+
query?: Dictionary<string | (string | null)[] | null | undefined>;
112112
params?: Dictionary<string>;
113113
append?: boolean;
114114
replace?: boolean;
@@ -118,7 +118,7 @@ export interface Route {
118118
path: string;
119119
name?: string;
120120
hash: string;
121-
query: Dictionary<string | string[]>;
121+
query: Dictionary<string | (string | null)[]>;
122122
params: Dictionary<string>;
123123
fullPath: string;
124124
matched: RouteRecord[];

types/test/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const route: Route = router.currentRoute;
105105
const path: string = route.path;
106106
const name: string | undefined = route.name;
107107
const hash: string = route.hash;
108-
const query: string | string[] = route.query["foo"];
108+
const query: string | (string | null)[] | null = route.query["foo"];
109109
const params: string = route.params["bar"];
110110
const fullPath: string = route.fullPath;
111111
const redirectedFrom: string | undefined = route.redirectedFrom;
@@ -149,6 +149,9 @@ router.push({
149149
},
150150
query: {
151151
bar: "bar",
152+
empty: null,
153+
removed: undefined,
154+
withEmpty: ["1", null],
152155
foo: ["foo1", "foo2"]
153156
},
154157
hash: "hash"

0 commit comments

Comments
 (0)