Skip to content

Commit

Permalink
feat(types): improve setActivePinia types
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Apr 18, 2023
1 parent 65debf9 commit 1650c6e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/pinia/src/rootStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ export let activePinia: Pinia | undefined
*
* @param pinia - Pinia instance
*/
export const setActivePinia = (pinia: Pinia | undefined) =>
(activePinia = pinia)
// @ts-expect-error: cannot constrain the type of the return
export const setActivePinia: _SetActivePinia = (pinia) => (activePinia = pinia)

interface _SetActivePinia {
(pinia: Pinia): Pinia
(pinia: undefined): undefined
(pinia: Pinia | undefined): Pinia | undefined
}

/**
* Get the currently active pinia if there is any.
Expand Down

0 comments on commit 1650c6e

Please sign in to comment.