Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
brunomperes opened this issue Mar 1, 2022 · 0 comments · Fixed by #13068
Closed

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

brunomperes opened this issue Mar 1, 2022 · 0 comments · Fixed by #13068

Comments

@brunomperes
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant