title: Vue Vuex with Typescript Vuex object not known type
body: <p>I am having issues trying to get Vuex with Typescript working. I did an example without typescript which worked just fine as shown first below. I am creating a Vuex module and then adding it as shown below</p>
  <p>src -&gt; store -&gt; index.js</p>
  <pre><code>import Vue from 'vue';
  import Vuex from 'vuex';
  import robotsModule from './modules/products';
  
  Vue.use(Vuex);
  
  export default new Vuex.Store({
    modules: {
      products: productsModule
    },
  });
  </code></pre>
  <p>src -&gt; store -&gt; modules -&gt; products.js</p>
  <pre><code>import axios from 'axios';
  
  export default {
    namespaced: true,
    state: {
      products: [],
    },
    mutations: {
      addProduct(state, product) {
        state.products.push(product);
      },
      updateProduct(state, products) {
        state.parts = products;
      },
    },
    actions: {
      getProducts({ commit }) {
        axios
          .get('/api/products')
          .then(result =&gt; commit('updateProduct', result.data))
          .catch(console.error);
      }
    },
  };
  </code></pre>
  <p>Now when I want to use typescript it keeps complaining that</p>
  <blockquote>
  <p>&quot;Binding element 'commit' implicitly has an 'any' type.&quot;</p>
  </blockquote>
  <p>As you can see I have currently specified the state as <strong>any</strong> which also seems wrong.
  How do I make this work nicely with typescript?</p>
  <p>src -&gt; store -&gt; modules -&gt; products.ts</p>
  <pre><code>import axios from 'axios';
  import { Product } from '@/models/product';
  
  export default {
    namespaced: true,
    state: {
      products: new Array&lt;Product&gt;(),
    },
    mutations: {
      updateProducts(state: any, products: Product[]) {
        state.products = products;
      },
      addProduct(state: any, product: Product) {
        state.products.push(product);
      },
    },
    actions: {
      getProducts({ commit }) {
        axios
          .get('/api/products')
          .then(result =&gt; commit('updateProducts', result.data))
          .catch(console.error);
      },
    },
  };
  </code></pre>