]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor: fix type errors
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 4 Nov 2021 17:52:02 +0000 (18:52 +0100)
committerEduardo San Martin Morote <posva@users.noreply.github.com>
Thu, 30 Jun 2022 07:59:00 +0000 (09:59 +0200)
__tests__/matcher/resolve.spec.ts
__tests__/utils.ts
src/matcher/types.ts
src/router.ts

index c286a76239c445b01fa702e59bcc16781921c0b7..8bff76ae07c2c89efab36881800743e29f2ba3fb 100644 (file)
@@ -6,21 +6,12 @@ import {
   MatcherLocationRaw,
   MatcherLocation,
 } from '../../src/types'
-import { MatcherLocationNormalizedLoose, RouteRecordViewLoose } from '../utils'
+import { MatcherLocationNormalizedLoose } from '../utils'
 import { mockWarn } from 'jest-mock-warn'
 import { defineComponent } from '@vue/runtime-core'
 
 const component: RouteComponent = defineComponent({})
 
-const baseRouteRecordNormalized: RouteRecordViewLoose = {
-  instances: {},
-  enterCallbacks: {},
-  aliasOf: undefined,
-  components: null,
-  path: '',
-  props: {},
-}
-
 // for normalized records
 const components = { default: component }
 
@@ -241,7 +232,6 @@ describe('RouterMatcher.resolve', () => {
           matched: [
             {
               path: '/p',
-              // @ts-expect-error: doesn't matter
               children,
               components,
               aliasOf: expect.objectContaining({ path: '/parent' }),
@@ -583,7 +573,6 @@ describe('RouterMatcher.resolve', () => {
           matched: [
             {
               path: '/parent',
-              // @ts-expect-error
               children,
               components,
               aliasOf: undefined,
@@ -1036,10 +1025,7 @@ describe('RouterMatcher.resolve', () => {
           name: 'child-b',
           path: '/foo/b',
           params: {},
-          matched: [
-            Foo as any,
-            { ...ChildB, path: `${Foo.path}/${ChildB.path}` },
-          ],
+          matched: [Foo, { ...ChildB, path: `${Foo.path}/${ChildB.path}` }],
         }
       )
     })
index 35f7d6334de41c7df02fc0c0c2ba236ccf50233c..7878291a51fb597076259341480a74e377eed43e 100644 (file)
@@ -58,7 +58,7 @@ export interface RouteRecordViewLoose
   enterCallbacks: Record<string, Function[]>
   props: Record<string, _RouteRecordProps>
   aliasOf: RouteRecordViewLoose | undefined
-  children?: RouteRecordViewLoose[]
+  children?: RouteRecordRaw[]
   components: Record<string, RouteComponent> | null | undefined
 }
 
index a0c33b36175a62730be503580fe3a3bf21a78ce0..cf8e0d2e02a588be683b27e56a79d0ecdf02da1a 100644 (file)
@@ -4,6 +4,7 @@ import {
   _RouteRecordBase,
   _RouteRecordProps,
   NavigationGuardNextCallback,
+  RouteRecordSingleViewWithChildren,
 } from '../types'
 import { ComponentPublicInstance } from 'vue'
 
@@ -29,9 +30,9 @@ export interface RouteRecordNormalized {
    */
   components: RouteRecordMultipleViews['components'] | null | undefined
   /**
-   * {@inheritDoc _RouteRecordBase.components}
+   * Nested route records.
    */
-  children: Exclude<_RouteRecordBase['children'], void>
+  children: RouteRecordSingleViewWithChildren['children']
   /**
    * {@inheritDoc _RouteRecordBase.meta}
    */
index 49ccae3cce80953e8743a44edc02fe47963223a0..dee1f9b9df4af4e993b91a4768d35395ff64a253 100644 (file)
@@ -50,7 +50,6 @@ import {
   reactive,
   unref,
   computed,
-  ref,
 } from 'vue'
 import { RouteRecord, RouteRecordNormalized } from './matcher/types'
 import {