]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
test(dts): fix
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 28 Sep 2020 16:37:09 +0000 (18:37 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 28 Sep 2020 16:37:09 +0000 (18:37 +0200)
src/index.ts
src/types.ts
test-dts/deprecated.test-d.ts [new file with mode: 0644]
test-dts/store.test-d.ts

index 55b5466924eb49aee94e2bb0ad029fb8db4b74c8..e14d3744073db2dc437c4917356523eb09b9a9a4 100644 (file)
@@ -1,17 +1,8 @@
-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'
index 93c7a9c882967a3b4f4984a45b3b1532eef08cef..2ffa164f26d186282ae46d9169d4f055d9cacc49 100644 (file)
@@ -111,24 +111,3 @@ export type GenericStore = Store<
   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
-    }
-  }
-}
diff --git a/test-dts/deprecated.test-d.ts b/test-dts/deprecated.test-d.ts
new file mode 100644 (file)
index 0000000..d9ee9d1
--- /dev/null
@@ -0,0 +1,23 @@
+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
index 57d1ba5a903c8df312aaf9446b05c20b6f8c1d23..1858f57f8f41153ea5805fcb3b319a52e6b8b846 100644 (file)
@@ -10,7 +10,7 @@ const useStore = defineStore({
   },
 })
 
-const store = useStore()
+let store = useStore()
 
 // FIXME: this should not be there anymore
 expectType<{ a: 'on' | 'off' }>(store.state)