Skip to content

declaration of beforeRouteEnter(to,from,next) hook should be updated #1863

Open
@doommm

Description

@doommm

Version

3.0.1

Reproduction link

https://jsfiddle.net/doommm/50wL7mdz/74369/

Steps to reproduce

  • Vue 2.5.3
  • Vue-class-component 6.1.0
  • Typescript 2.6.1
  • vscode 1.17.2, vetur 0.11.0

I found that in declaration file(types/router.d.ts), there's a type named NavigationGuard used for beforeRouteEnter and other two hooks. The function declaration of next is ((vm: Vue) => any) | void) => void, and should it be updated so we could access all members declared in class(or object)?
I wrote three examples to explain my confusion.

  1. In .vue file with object literal style, i cant access my own properties.
  2. In .vue file with vue-class-component, if i add an type identifier manually, it works. no error. if not, error.
  3. In separate .ts file with vue-class-component, whether i add identifier or not, got error. But if i roll back to typescript 2.5.3, and add type identifier, it works.

I think the declaration should be updated(Generics? T extends Vue or ?), but i'm not sure about that. Sorry for my poor english If I dont describe the problem clearly.

What is expected?

all class(object) members should be accessed in vm.propertyName

What is actually happening?

We could only access members of Vue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypescriptTypescript related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions