-
-
Notifications
You must be signed in to change notification settings - Fork 975
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(types): correctly type global extensions
Fix #630
- Loading branch information
Showing
4 changed files
with
56 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import type { Pinia } from './rootStore' | ||
import type { Store, StoreGeneric } from './types' | ||
|
||
// Extensions of Vue types to be appended manually | ||
// https://github.com/microsoft/rushstack/issues/2090 | ||
// https://github.com/microsoft/rushstack/issues/1709 | ||
|
||
// @ts-ignore: works on Vue 2, fails in Vue 3 | ||
declare module 'vue/types/vue' { | ||
interface Vue { | ||
/** | ||
* Currently installed pinia instance. | ||
*/ | ||
$pinia: Pinia | ||
|
||
/** | ||
* Cache of stores instantiated by the current instance. Used by map | ||
* helpers. | ||
* | ||
* @internal | ||
*/ | ||
_pStores?: Record<string, Store> | ||
} | ||
} | ||
|
||
// @ts-ignore: works on Vue 2, fails in Vue 3 | ||
declare module 'vue/types/options' { | ||
interface ComponentOptions<V> { | ||
/** | ||
* Pinia instance to install in your application. Should be passed to the | ||
* root Vue. | ||
*/ | ||
pinia?: Pinia | ||
} | ||
} | ||
|
||
// @ts-ignore: works on Vue 3, fails in Vue 2 | ||
declare module '@vue/runtime-core' { | ||
export interface ComponentCustomProperties { | ||
/** | ||
* Access to the application's Pinia | ||
*/ | ||
$pinia: Pinia | ||
|
||
/** | ||
* Cache of stores instantiated by the current instance. Used by devtools to | ||
* list currently used stores. | ||
* | ||
* @internal | ||
*/ | ||
_pStores?: Record<string, StoreGeneric> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,3 +69,5 @@ export { | |
PiniaPlugin, | ||
PiniaVuePlugin, | ||
} from './vue2-plugin' | ||
|
||
export * from './globalExtensions' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters