Skip to content

4.2.0 - Type error when extending ComponentCustomProperties #1843

@parafeu

Description

@parafeu

Reproduction

https://stackblitz.com/edit/vitejs-vite-9iezka?file=src/vue.d.ts

Steps to reproduce the bug

Using vite, create a d.ts file extending ComponentCustomProperties
Use $route or $router in any component template.
Try to build your code with npm run build

Expected behavior

When using vue-router 4.1.6, there is no compilation error.

Actual behavior

Here is the error durring code build :

error TS2339: Property '$route' does not exist on type '{ $: ComponentInternalInstance; $data: {}; $props: { key?: string | number | symbol | undefined; ref?: VNodeRef | undefined; ref_for?: boolean | undefined; ... 8 more ...; style?: unknown; }; ... 10 more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (arg...'.

2   <div>{{ $route.name }}</div>
            ~~~~~~


Found 1 error in src/pages/Home.vue:2·

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions