Skip to content

Commit

Permalink
Fix LocationQuery type
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andresespinosapc authored Aug 10, 2022
1 parent df83652 commit 41cb329
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/router/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41cb329

Please sign in to comment.