From: Eduardo San Martin Morote Date: Thu, 28 Oct 2021 09:22:51 +0000 (+0200) Subject: refactor: remove deprecations X-Git-Tag: pinia@2.0.1~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7dd6b1b8480e9328f317904c3c75169bf9bc29c6;p=thirdparty%2Fvuejs%2Fpinia.git refactor: remove deprecations --- diff --git a/packages/pinia/src/index.ts b/packages/pinia/src/index.ts index dd52d97e..99fbd400 100644 --- a/packages/pinia/src/index.ts +++ b/packages/pinia/src/index.ts @@ -3,7 +3,13 @@ */ export { setActivePinia, getActivePinia } from './rootStore' export { createPinia } from './createPinia' -export type { Pinia, PiniaStorePlugin, PiniaPluginContext } from './rootStore' +export type { + Pinia, + // TODO: remove in next release + PiniaStorePlugin, + PiniaPlugin, + PiniaPluginContext, +} from './rootStore' export { defineStore, skipHydrate } from './store' export type { StoreActions, StoreGetters, StoreState } from './store' @@ -12,8 +18,6 @@ export type { StateTree, Store, StoreGeneric, - // TODO: remove in release - GenericStore, StoreDefinition, _StoreWithGetters, _GettersTree, @@ -64,10 +68,6 @@ export type { export { acceptHMRUpdate } from './hmr' -export { - // TODO: remove in release and deprecate PiniaStorePlugin in favor of PiniaPlugin - PiniaPlugin, - PiniaVuePlugin, -} from './vue2-plugin' +export { PiniaVuePlugin } from './vue2-plugin' export * from './globalExtensions' diff --git a/packages/pinia/src/rootStore.ts b/packages/pinia/src/rootStore.ts index 2713f4cc..4c96c81b 100644 --- a/packages/pinia/src/rootStore.ts +++ b/packages/pinia/src/rootStore.ts @@ -129,9 +129,9 @@ export interface PiniaPluginContext< } /** - * Plugin to extend every store + * Plugin to extend every store. */ -export interface PiniaStorePlugin { +export interface PiniaPlugin { /** * Plugin to extend every store. Returns an object to extend the store or * nothing. @@ -142,3 +142,9 @@ export interface PiniaStorePlugin { PiniaCustomProperties & PiniaCustomStateProperties > | void } + +/** + * Plugin to extend every store. + * @deprecated use PiniaPlugin instead + */ +export type PiniaStorePlugin = PiniaPlugin diff --git a/packages/pinia/src/store.ts b/packages/pinia/src/store.ts index 9ab67fa0..51963231 100644 --- a/packages/pinia/src/store.ts +++ b/packages/pinia/src/store.ts @@ -371,23 +371,9 @@ function createSetupStore< $patch, $reset, $subscribe(callback, options = {}) { - /* istanbul ignore if */ - if (__DEV__ && typeof options === 'boolean') { - console.warn( - `[🍍]: store.$subscribe() no longer accepts a boolean as the 2nd parameter:\n` + - `Replace "store.$subscribe(fn, ${String( - options - )})" with "store.$subscribe(fn, { detached: ${String( - options - )} })".\nThis will fail in production.` - ) - options = { detached: options } - } - const _removeSubscription = addSubscription( subscriptions, callback, - // @ts-expect-error: until the deprecation is removed options.detached ) const stopWatcher = scope.run(() => diff --git a/packages/pinia/src/types.ts b/packages/pinia/src/types.ts index 05dd5afb..31d192ac 100644 --- a/packages/pinia/src/types.ts +++ b/packages/pinia/src/types.ts @@ -358,22 +358,6 @@ export interface _StoreWithState< options?: { detached?: boolean } & WatchOptions ): () => void - /** - * Setups a callback to be called whenever the state changes. It also returns - * a function to remove the callback. Note than when calling - * `store.$subscribe()` inside of a component, it will be automatically - * cleanup up when the component gets unmounted unless `detached` is set to - * true. - * - * @deprecated use `store.$subscribe(fn, { detached: true })` instead. - * - * @param callback - callback passed to the watcher - * @param detached - detach the subscription from the context this is called - * from - * @returns function that removes the watcher - */ - $subscribe(callback: SubscriptionCallback, detached?: boolean): () => void - /** * @alpha Please send feedback at https://github.com/posva/pinia/issues/240 * Setups a callback to be called every time an action is about to get @@ -494,25 +478,6 @@ export type StoreGeneric = Store< _ActionsTree > -/** - * Generic and type-unsafe version of Store. Doesn't fail on access with - * strings, making it much easier to write generic functions that do not care - * about the kind of store that is passed. - * @deprecated Use `StoreGeneric` instead - */ -export type GenericStore< - Id extends string = string, - S extends StateTree = StateTree, - G /* extends GettersTree */ = _GettersTree, - // has the actions without the context (this) for typings - A /* extends ActionsTree */ = _ActionsTree -> = _StoreWithState & - UnwrapRef & - _StoreWithGetters & - A & - PiniaCustomProperties & - PiniaCustomStateProperties - /** * Return type of `defineStore()`. Function that allows instantiating a store. */ @@ -711,11 +676,4 @@ export interface DefineStoreOptionsInPlugin< * Defaults to an empty object if no actions are defined. */ actions: A - - /** - * Id of the store. Only available when the options API is used. - * - * @deprecated Use `store.$id` instead. - */ - id?: Id } diff --git a/packages/pinia/src/vue2-plugin.ts b/packages/pinia/src/vue2-plugin.ts index f11d6f63..1b3bde6b 100644 --- a/packages/pinia/src/vue2-plugin.ts +++ b/packages/pinia/src/vue2-plugin.ts @@ -69,8 +69,3 @@ export const PiniaVuePlugin: Plugin = function (_Vue) { }, }) } - -/** - * @deprecated use `PiniaVuePlugin` instead. - */ -export const PiniaPlugin = PiniaVuePlugin