Skip to content

Commit 321d807

Browse files
committed
fix(types): allow using InjectionKey as valid property key
close #5089
1 parent 1fbfa69 commit 321d807

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: packages/dts-test/inject.test-d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
type InjectionKey,
33
type Ref,
44
createApp,
5+
defineComponent,
56
inject,
67
provide,
78
ref,
@@ -52,3 +53,9 @@ provide<Cube>(123, { size: 'foo' })
5253
const app = createApp({})
5354
// @ts-expect-error
5455
app.provide(injectionKeyRef, ref({}))
56+
57+
defineComponent({
58+
provide: {
59+
[injectionKeyRef]: { size: 'foo' },
60+
},
61+
})

Diff for: packages/runtime-core/src/apiInject.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { currentRenderingInstance } from './componentRenderContext'
44
import { currentApp } from './apiCreateApp'
55
import { warn } from './warning'
66

7-
export interface InjectionKey<T> extends Symbol {}
7+
interface InjectionConstraint<T> {}
8+
9+
export type InjectionKey<T> = symbol & InjectionConstraint<T>
810

911
export function provide<T, K = InjectionKey<T> | string | number>(
1012
key: K,

0 commit comments

Comments
 (0)