Skip to content

Commit d36329c

Browse files
committed
fix: vuex useStore in script setup crashes inspector
1 parent b06d7f1 commit d36329c

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

packages/shared-utils/src/util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ function replacerForInternal (key) {
240240
return `[native VNode <${val.tag}>]`
241241
} else if (typeof HTMLElement !== 'undefined' && val instanceof HTMLElement) {
242242
return encodeCache.cache(val, () => getCustomHTMLElementDetails(val))
243+
} else if (val.constructor?.name === 'Store' && val._wrappedGetters) {
244+
return `[object Store]`
245+
} else if (val.currentRoute) {
246+
return `[object Router]`
243247
}
244248
const customDetails = getCustomObjectDetails(val, proto)
245249
if (customDetails != null) return customDetails

packages/shell-dev-vue3/src/SetupScript.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script setup>
22
import Child from './Child.vue'
33
import { ref, computed, reactive } from 'vue'
4+
import { useStore } from 'vuex'
5+
import { useRouter } from 'vue-router'
46
57
const myObj = reactive({
68
foo: 'bar',
@@ -19,6 +21,13 @@ const state2 = reactive({
1921
function onClick () {
2022
count.value++
2123
}
24+
25+
const throws = computed(() => { throw new Error('oops') })
26+
27+
const store = useStore()
28+
const throwsWithVuex = computed(() => store.getters.throws)
29+
30+
const router = useRouter()
2231
</script>
2332

2433
<template>

packages/shell-dev-vue3/src/store.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const store = createStore({
99
},
1010
getters: {
1111
answer: (state) => state.answer,
12+
throws: () => {
13+
throw new Error('getter error')
14+
},
1215
},
1316
mutations: {
1417
increment (state) {

0 commit comments

Comments
 (0)