Skip to content

Commit 41cb329

Browse files
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.
1 parent df83652 commit 41cb329

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/router/src/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type LocationQueryValueRaw = LocationQueryValue | number | undefined
2828
*/
2929
export type LocationQuery = Record<
3030
string,
31-
LocationQueryValue | LocationQueryValue[]
31+
LocationQueryValue | LocationQueryValue[] | undefined
3232
>
3333
/**
3434
* Loose {@link LocationQuery} object that can be passed to functions like

0 commit comments

Comments
 (0)