From 41cb32949f4eeb0b6c360049ec3d58aba5e81c89 Mon Sep 17 00:00:00 2001 From: Andres Espinosa Date: Wed, 10 Aug 2022 11:46:43 -0400 Subject: [PATCH] Fix LocationQuery type When a query param is not present the query value is `undefined`, but the type is only `string | null`. Here is the extract of code where I had this problem: ``` const route = useRoute(); const sortBy = ref(route.query.sort_by.toString()) ``` I got `Cannot read property 'toString' of undefined` but the linter didn't give any errors. --- packages/router/src/query.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/router/src/query.ts b/packages/router/src/query.ts index 94d914618..133123e34 100644 --- a/packages/router/src/query.ts +++ b/packages/router/src/query.ts @@ -28,7 +28,7 @@ export type LocationQueryValueRaw = LocationQueryValue | number | undefined */ export type LocationQuery = Record< string, - LocationQueryValue | LocationQueryValue[] + LocationQueryValue | LocationQueryValue[] | undefined > /** * Loose {@link LocationQuery} object that can be passed to functions like