@@ -24,6 +24,33 @@ import {
2424} from './componentRenderUtils'
2525import { warn } from './warning'
2626
27+ /**
28+ * Custom properties added to component instances in any way and can be accessed through `this`
29+ *
30+ * @example
31+ * Here is an example of adding a property `$router` to every component instance:
32+ * ```ts
33+ * import { createApp } from 'vue'
34+ * import { Router, createRouter } from 'vue-router'
35+ *
36+ * declare module '@vue/runtime-core' {
37+ * interface ComponentCustomProperties {
38+ * $router: Router
39+ * }
40+ * }
41+ *
42+ * // effectively adding the router to every component instance
43+ * const app = createApp({})
44+ * const router = createRouter()
45+ * app.config.globalProperties.$router = router
46+ *
47+ * const vm = app.mount('#app')
48+ * // we can access the router from the instance
49+ * vm.$router.push('/')
50+ * ```
51+ */
52+ export interface ComponentCustomProperties { }
53+
2754// public properties exposed on the proxy, which is used as the render context
2855// in templates (as `this` in the render option)
2956export type ComponentPublicInstance <
@@ -53,7 +80,8 @@ export type ComponentPublicInstance<
5380 UnwrapRef < B > &
5481 D &
5582 ExtractComputedReturns < C > &
56- M
83+ M &
84+ ComponentCustomProperties
5785
5886const publicPropertiesMap : Record <
5987 string ,
0 commit comments