-
Before, I write: const props = defineProps<{
id: number
type?: AssetType
}>()
definePage({
props: route => ({
id: +route.params.id,
type: route.params.type,
}),
alias: '/ad/:id/:type?',
}) But after upgrading to 0.10.*, there is an error Currently, I use const props = defineProps<{
id: number
type?: AssetType
}>()
definePage({
props: route => ({
id: 'id' in route.params ? +route.params.id : undefined,
type: 'type' in route.params ? route.params.type : undefined,
}),
alias: '/ad/:id/:type?',
}) Is there any good practice? |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Sep 19, 2024
Replies: 1 comment
-
For the moment you can cast the route with |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
a1mersnow
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the moment you can cast the route with
as RouteLocationNormalizedLoaded<'/users/[id]'>
. Maybe in the future,definePage
can be imported from a local./$types
but I think it will be simply easier to directly useuseRoute()
, which is easier to type, because in the future it will also allow other types than string and string[]