From: Eduardo San Martin Morote Date: Thu, 4 Nov 2021 17:52:02 +0000 (+0100) Subject: refactor: fix type errors X-Git-Tag: v4.1.0~136 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=148cce3286a9d8bc83cb9dc281336acf75c26a3a;p=thirdparty%2Fvuejs%2Frouter.git refactor: fix type errors --- diff --git a/__tests__/matcher/resolve.spec.ts b/__tests__/matcher/resolve.spec.ts index c286a762..8bff76ae 100644 --- a/__tests__/matcher/resolve.spec.ts +++ b/__tests__/matcher/resolve.spec.ts @@ -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}` }], } ) }) diff --git a/__tests__/utils.ts b/__tests__/utils.ts index 35f7d633..7878291a 100644 --- a/__tests__/utils.ts +++ b/__tests__/utils.ts @@ -58,7 +58,7 @@ export interface RouteRecordViewLoose enterCallbacks: Record props: Record aliasOf: RouteRecordViewLoose | undefined - children?: RouteRecordViewLoose[] + children?: RouteRecordRaw[] components: Record | null | undefined } diff --git a/src/matcher/types.ts b/src/matcher/types.ts index a0c33b36..cf8e0d2e 100644 --- a/src/matcher/types.ts +++ b/src/matcher/types.ts @@ -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} */ diff --git a/src/router.ts b/src/router.ts index 49ccae3c..dee1f9b9 100644 --- a/src/router.ts +++ b/src/router.ts @@ -50,7 +50,6 @@ import { reactive, unref, computed, - ref, } from 'vue' import { RouteRecord, RouteRecordNormalized } from './matcher/types' import {