With module merging in TS, we can override module interfaces. However it is limited, in the case of the Vuex types it's impossible to compose full typing layer in components.
If we make it optional to install vuex/types/vue.d.ts
then we can do our own manual declaration. Which will enable fully typed structures. I would also rename to vuex/types/install.d.ts
Once we allow custom installation we can do something similar to this to enable full typing layer.
import Vue from 'vue' import * as Vuex from 'vuex' import { RootState } from 'store/types' Vue.use(Vuex); export class Store { store: Vuex.Store<RootState>; static instance: Store; constructor() { this.store = new Vuex.Store<RootState>{ strict: true }); } get() { return this.store } } declare module "vue/types/options" { interface ComponentOptions<V extends Vue> { store?: Vuex.Store<RootState>; } } declare module "vue/types/vue" { interface Vue { $store: Vuex.Store<RootState>; } } export default Store
mitchell-garcia, skovmand, lambdalisue, bichikim, ThreeScreenStudios and 15 more
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4