Skip to content

Commit e45fe3c

Browse files
committed
chore(createContext): add contextkey type
1 parent 0ef3ed4 commit e45fe3c

File tree

1 file changed

+4
-2
lines changed
  • packages/0/src/factories/createContext

1 file changed

+4
-2
lines changed

packages/0/src/factories/createContext/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { inject, provide } from 'vue'
44
// Types
55
import type { App, InjectionKey } from 'vue'
66

7+
export type ContextKey<Z> = InjectionKey<Z> | string
8+
79
/**
810
* A simple wrapper for tapping into a v0 namespace
911
* @param key The provided string or InjectionKey
1012
* @template Z The type values for the context.
1113
* @returns A function that retrieves context
1214
*/
13-
export function useContext<Z> (key: InjectionKey<Z> | string) {
15+
export function useContext<Z> (key: ContextKey<Z>) {
1416
return function (): Z {
1517
const contextValue = inject<Z>(key)
1618

@@ -32,7 +34,7 @@ export function useContext<Z> (key: InjectionKey<Z> | string) {
3234
* @see https://vuejs.org/guide/components/provide-inject
3335
* @see https://0.vuetifyjs.com/composables/foundation/create-context
3436
*/
35-
export function createContext<Z> (key: InjectionKey<Z> | string) {
37+
export function createContext<Z> (key: ContextKey<Z>) {
3638
function provideContext (value: Z, app?: App) {
3739
app ? app.provide(key, value) : provide(key, value)
3840

0 commit comments

Comments
 (0)