vue icon indicating copy to clipboard operation
vue copied to clipboard

serverPrefetch's `this` type doesn't include component properties

Open brunomperes opened this issue 2 years ago • 0 comments

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.

brunomperes avatar Mar 01 '22 18:03 brunomperes