4.0.0-beta.1
https://github.com/ChrisShank/vue-next-webpack-preview
Remove the type declaration of 'useStore' I added in 'vuex-shim.d.ts', and there will be a compile-time TS error.
The type for useStore to exist.
On the line:
import { useStore } from 'vuex'
There is an error:
TS2614: Module 'vue-next-webpack-preview/node_modules/vuex/types"' has no exported member 'useStore'. Did you mean to use 'import useStore from "vue-next-webpack-preview/node_modules/vuex/types"' instead?
@ChrisShank Override the vuex's type definition in TypeScript.
declare module "vuex" {
function useStore<T = any>(key?: string): T
}
It seems that the type is difficult to cover, you can do this:
// @ts-ignore
import { createStore, useStore as useVuexStore } from 'vuex'
const store = createStore<StoreState>({})
export default store
export function useStore(): typeof store {
return useVuexStore()
}
@surmon-china I currently am here
I think that a type should either be included with the package (similar to the one you first mentioned) or documented that the user is expected to provide their own shim.
Thanks for the report! Yea we must add this one 馃憤
Most helpful comment
It seems that the type is difficult to cover, you can do this: