]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
chore: playground fixes
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 21 Jan 2026 21:57:16 +0000 (22:57 +0100)
committerEduardo San Martin Morote <posva@users.noreply.github.com>
Thu, 29 Jan 2026 16:38:08 +0000 (17:38 +0100)
packages/playground-file-based/src/main.ts
packages/playground-file-based/src/pages/[...path].vue
packages/playground-file-based/src/params/date.ts

index 817377cd5d1e1bcf73040bd4674b35b204aff080..3801f5da2b2a8807ac6802e456b69072e7c7976c 100644 (file)
@@ -11,8 +11,10 @@ const app = createApp(App)
 
 app.use(createPinia())
 app.use(PiniaColada, {})
-// @ts-expect-error: FIXME: should be doable
-app.use(DataLoaderPlugin, { router })
+app.use(DataLoaderPlugin, {
+  // FIXME: should be doable without `as any`
+  router: router as any,
+})
 app.component('RouterLink', RouterLink)
 app.component('RouterView', RouterView)
 app.use(router)
index 282358e0a6ed62740203921efa985b41a76ce269..71056cbd2e8a1b2a5773ad1ed4f040ee22c5eb87 100644 (file)
@@ -4,7 +4,13 @@ import doc from '../main.ts?raw'
 
 const route = useRoute()
 const router = useRouter()
-route.params.path
+// router.push({
+//   name: 'not-found',
+//   params: {
+//     path: 'yoooo',
+//   }
+// })
+// route.params.optionalWhen
 
 console.log('typeof', typeof route.params.active)
 console.log('value', route.params.active)
@@ -28,7 +34,6 @@ definePage({
       },
       other: {
         parser: 'bool',
-        default: false,
       },
       active: {
         parser: 'bool',
@@ -44,6 +49,10 @@ definePage({
         default: -1,
       },
 
+      // optionalWhen: {
+      //   parser: 'date',
+      // },
+      //
       when: {
         parser: 'date',
         default: () => new Date(),
index eb85e9bdcc9b6f18e7647dac8f84c315f7f1409e..76a315a7323737181b8df6aac339f0fa3e6a742b 100644 (file)
@@ -20,11 +20,13 @@ function toString(value: Date): string {
 }
 
 export const parser = defineParamParser({
-  get: (value: string | string[] | null) => {
+  get: value => {
     if (!value) {
       throw miss()
     }
-    return Array.isArray(value) ? value.map(toDate) : toDate(value)
+    return Array.isArray(value)
+      ? value.filter((v): v is string => !!v).map(toDate)
+      : toDate(value)
   },
   set: (value: Date | Date[]) =>
     Array.isArray(value) ? value.map(toString) : toString(value),