"funding": "https://github.com/sponsors/posva",
"scripts": {
"build": "rimraf dist && rollup -c ../../rollup.config.js --environment TARGET:pinia",
- "build:dts": "api-extractor run --local --verbose",
+ "build:dts": "api-extractor run --local --verbose && tail -n +3 ./src/globalExtensions.ts >> dist/pinia.d.ts",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . -l pinia -r 1",
"test:dts": "tsc -p ./test-dts/tsconfig.json",
"dev": "yarn run test:unit --watchAll",
--- /dev/null
+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>
+ }
+}
_testing?: boolean
}
-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>
- }
-}
-
export const piniaSymbol = (
__DEV__ ? Symbol('pinia') : /* istanbul ignore next */ Symbol()
) as InjectionKey<Pinia>