-import { defineStore } from './store'
export {
setActiveReq,
setStateProvider,
getRootState,
createPinia,
} from './rootStore'
-
-function createStore(options: Parameters<typeof defineStore>[0]) {
- console.warn(
- '[🍍]: "createStore" has been deprecated and will be removed on the sable release, use "defineStore" instead.'
- )
- return defineStore(options)
-}
-
-export { StateTree, StoreGetter, Store } from './types'
-export { createStore, defineStore }
+export { defineStore } from './store'
+export { createStore } from './deprecated'
Record<string, Method>,
Record<string, Method>
>
-
-export interface DevtoolHook {
- on(
- event: string,
- callback: (targetState: Record<string, StateTree>) => void
- ): void
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- emit(event: string, ...payload: any[]): void
-}
-
-// add the __VUE_DEVTOOLS_GLOBAL_HOOK__ variable to the global namespace
-declare global {
- interface Window {
- __VUE_DEVTOOLS_GLOBAL_HOOK__?: DevtoolHook
- }
- namespace NodeJS {
- interface Global {
- __VUE_DEVTOOLS_GLOBAL_HOOK__?: DevtoolHook
- }
- }
-}
--- /dev/null
+import { createStore, expectType } from './'
+
+const useDeprecated = createStore({
+ id: 'name',
+ state: () => ({ a: 'on' as 'on' | 'off', nested: { counter: 0 } }),
+ getters: {
+ upper() {
+ return this.a.toUpperCase()
+ },
+ },
+})
+
+const deprecatedStore = useDeprecated()
+
+expectType<{ a: 'on' | 'off' }>(deprecatedStore.state)
+expectType<number>(deprecatedStore.nested.counter)
+expectType<'on' | 'off'>(deprecatedStore.a)
+
+// @ts-expect-error
+deprecatedStore.nonExistant
+
+// @ts-expect-error
+deprecatedStore.nonExistant.stuff
},
})
-const store = useStore()
+let store = useStore()
// FIXME: this should not be there anymore
expectType<{ a: 'on' | 'off' }>(store.state)