Skip to content

serverPrefetch's this type doesn't include component properties #12488

@brunomperes

Description

@brunomperes

Version

2.6.14

Reproduction link

codesandbox.io

Steps to reproduce

Comment the helloWorld method, then uncomment it. This will trigger the type checking.

You should now see this syntax error on serverPrefetch code:
Screenshot 2022-03-01 at 19 17 18

What is expected?

methods, props and data properties should be available inside serverPrefetch's this type.

What is actually happening?

serverPrefetch's this is a generic Vue type that doesn't include current component info.


This seems to be a leftover. This issue was fixed for multiple ComponentOptions with this commit.

Then ssrPrefetch was added including the this: V type with this commit and further serverPrefetch kept it this commit.

This type is not needed:

diff --git a/types/options.d.ts b/types/options.d.ts
-  serverPrefetch?(this: V): Promise<void>;
+  serverPrefetch?(): Promise<void>;

I got to this bug trying to use a Vuex mapped mutation inside serverPrefetch.

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