From 3d6aca3510a28d588be092c9a42a4851fcf93d4a Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Fri, 20 Aug 2021 15:32:53 +0200 Subject: [PATCH] feat: use vuex 4 for vue3 --- package.json | 2 +- src/store/index.js | 7 ++----- src/types/shims-vue.d.ts | 15 +++++++++++++++ yarn.lock | 12 +++++++----- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index f08ad411..b456ddba 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "vue-router": "4.0.11", "vue-shortkey": "3.1.7", "vuedraggable": "2.24.3", - "vuex": "3.6.2", + "vuex": "4.0.2", "workbox-precaching": "6.3.0" }, "devDependencies": { diff --git a/src/store/index.js b/src/store/index.js index 26aac821..76768bea 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,5 +1,4 @@ -import Vue from 'vue' -import Vuex from 'vuex' +import { createStore } from 'vuex' import { CURRENT_LIST, ERROR_MESSAGE, @@ -21,9 +20,7 @@ import labels from './modules/labels' import ListService from '../services/list' -Vue.use(Vuex) - -export const store = new Vuex.Store({ +export const store = createStore({ strict: import.meta.env.DEV, modules: { config, diff --git a/src/types/shims-vue.d.ts b/src/types/shims-vue.d.ts index d9f24faa..0dcf2ed8 100644 --- a/src/types/shims-vue.d.ts +++ b/src/types/shims-vue.d.ts @@ -2,3 +2,18 @@ declare module '*.vue' { import Vue from 'vue' export default Vue } + +// https://next.vuex.vuejs.org/guide/migrating-to-4-0-from-3-x.html#typescript-support +import { ComponentCustomProperties } from 'vue' +import { Store } from 'vuex' + +declare module '@vue/runtime-core' { + // Declare your own store states. + interface State { + count: number + } + + interface ComponentCustomProperties { + $store: Store + } +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index b4c0adf7..b68743ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1785,7 +1785,7 @@ "@vue/compiler-dom" "3.2.14" "@vue/shared" "3.2.14" -"@vue/devtools-api@^6.0.0-beta.14": +"@vue/devtools-api@^6.0.0-beta.11", "@vue/devtools-api@^6.0.0-beta.14": version "6.0.0-beta.15" resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.0.0-beta.15.tgz#ad7cb384e062f165bcf9c83732125bffbc2ad83d" integrity sha512-quBx4Jjpexo6KDiNUGFr/zF/2A4srKM9S9v2uHgMXSU//hjgq1eGzqkIFql8T9gfX5ZaVOUzYBP3jIdIR3PKIA== @@ -6951,10 +6951,12 @@ vuedraggable@2.24.3: dependencies: sortablejs "1.10.2" -vuex@3.6.2: - version "3.6.2" - resolved "https://registry.yarnpkg.com/vuex/-/vuex-3.6.2.tgz#236bc086a870c3ae79946f107f16de59d5895e71" - integrity sha512-ETW44IqCgBpVomy520DT5jf8n0zoCac+sxWnn+hMe/CzaSejb/eVw2YToiXYX+Ex/AuHHia28vWTq4goAexFbw== +vuex@4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/vuex/-/vuex-4.0.2.tgz#f896dbd5bf2a0e963f00c67e9b610de749ccacc9" + integrity sha512-M6r8uxELjZIK8kTKDGgZTYX/ahzblnzC4isU1tpmEuOIIKmV+TRdc+H4s8ds2NuZ7wpUTdGRzJRtoj+lI+pc0Q== + dependencies: + "@vue/devtools-api" "^6.0.0-beta.11" w3c-hr-time@^1.0.2: version "1.0.2"