Skip to content

Commit

Permalink
fix(types): allow null/undefined in query params
Browse files Browse the repository at this point in the history
fix #2605
  • Loading branch information
posva committed Feb 5, 2019
1 parent 658eee6 commit ca30a75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions types/router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export interface Location {
name?: string;
path?: string;
hash?: string;
query?: Dictionary<string | string[]>;
query?: Dictionary<string | (string | null)[] | null | undefined>;
params?: Dictionary<string>;
append?: boolean;
replace?: boolean;
Expand All @@ -118,7 +118,7 @@ export interface Route {
path: string;
name?: string;
hash: string;
query: Dictionary<string | string[]>;
query: Dictionary<string | (string | null)[]>;
params: Dictionary<string>;
fullPath: string;
matched: RouteRecord[];
Expand Down
5 changes: 4 additions & 1 deletion types/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const route: Route = router.currentRoute;
const path: string = route.path;
const name: string | undefined = route.name;
const hash: string = route.hash;
const query: string | string[] = route.query["foo"];
const query: string | (string | null)[] | null = route.query["foo"];
const params: string = route.params["bar"];
const fullPath: string = route.fullPath;
const redirectedFrom: string | undefined = route.redirectedFrom;
Expand Down Expand Up @@ -149,6 +149,9 @@ router.push({
},
query: {
bar: "bar",
empty: null,
removed: undefined,
withEmpty: ["1", null],
foo: ["foo1", "foo2"]
},
hash: "hash"
Expand Down

0 comments on commit ca30a75

Please sign in to comment.