mirror of https://github.com/vuejs/core.git
parent
1fbfa6962b
commit
321d80758c
|
@ -2,6 +2,7 @@ import {
|
|||
type InjectionKey,
|
||||
type Ref,
|
||||
createApp,
|
||||
defineComponent,
|
||||
inject,
|
||||
provide,
|
||||
ref,
|
||||
|
@ -52,3 +53,9 @@ provide<Cube>(123, { size: 'foo' })
|
|||
const app = createApp({})
|
||||
// @ts-expect-error
|
||||
app.provide(injectionKeyRef, ref({}))
|
||||
|
||||
defineComponent({
|
||||
provide: {
|
||||
[injectionKeyRef]: { size: 'foo' },
|
||||
},
|
||||
})
|
||||
|
|
|
@ -4,7 +4,9 @@ import { currentRenderingInstance } from './componentRenderContext'
|
|||
import { currentApp } from './apiCreateApp'
|
||||
import { warn } from './warning'
|
||||
|
||||
export interface InjectionKey<T> extends Symbol {}
|
||||
interface InjectionConstraint<T> {}
|
||||
|
||||
export type InjectionKey<T> = symbol & InjectionConstraint<T>
|
||||
|
||||
export function provide<T, K = InjectionKey<T> | string | number>(
|
||||
key: K,
|
||||
|
|
Loading…
Reference in New Issue