Skip to content

Commit 4363a56

Browse files
committed
fix: check Function instance for store state rather than typeof
1 parent 4ac3903 commit 4363a56

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

packages/nuxt-typed-vuex/src/index.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
import { join, resolve } from 'upath'
22

3-
import type { Module, NuxtOptions } from '@nuxt/types'
3+
import type { Module } from '@nuxt/types'
44

55
import { name, version } from '../package.json'
66

77
/**
88
* @private
99
*/
1010
const nuxtTypedVuex: Module = function nuxtTypedVuex() {
11-
const nuxtOptions = this.nuxt.options as NuxtOptions
12-
13-
if (!nuxtOptions.store) console.warn('You do not have a store defined.')
11+
if (!this.options.store) console.warn('You do not have a store defined.')
1412

1513
this.addPlugin({
1614
src: resolve(__dirname, '../template/plugin.js'),
1715
fileName: 'nuxt-typed-vuex.js',
1816
options: {
19-
store: join(nuxtOptions.buildDir, 'store'),
17+
store: join(this.options.buildDir, 'store'),
2018
},
2119
})
2220

23-
nuxtOptions.build.transpile = /* istanbul ignore next */ nuxtOptions.build.transpile || []
24-
nuxtOptions.build.transpile.push(/typed-vuex/)
21+
this.options.build.transpile = /* istanbul ignore next */ this.options.build.transpile || []
22+
this.options.build.transpile.push(/typed-vuex/)
2523
}
2624

2725
;(nuxtTypedVuex as any).meta = { name, version }

packages/typed-vuex/src/accessor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const createAccessor = <T extends State, G, M, A, S extends NuxtModules>(
4242
})
4343
})
4444
const evaluatedState = state
45-
? typeof state === 'function'
45+
? state instanceof Function
4646
? state()
4747
: state
4848
: {}

0 commit comments

Comments
 (0)