vue
vue copied to clipboard
serverPrefetch's `this` type doesn't include component properties
Version
2.6.14
Reproduction link
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:

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.