Skip to content

Commit 1baa0a7

Browse files
ktsnyyx990803
authored andcommitted
fix(types): add inject option in functional component options type (#6530)
1 parent aa820cb commit 1baa0a7

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

types/options.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface ComponentOptions<V extends Vue> {
4747
filters?: { [key: string]: Function };
4848

4949
provide?: Object | (() => Object);
50-
inject?: { [key: string]: string | symbol } | Array<string>;
50+
inject?: { [key: string]: string | symbol } | string[];
5151

5252
model?: {
5353
prop?: string;
@@ -66,6 +66,7 @@ export interface ComponentOptions<V extends Vue> {
6666
export interface FunctionalComponentOptions {
6767
name?: string;
6868
props?: string[] | { [key: string]: PropOptions | Constructor | Constructor[] };
69+
inject?: { [key: string]: string | symbol } | string[];
6970
functional: boolean;
7071
render(this: never, createElement: CreateElement, context: RenderContext): VNode | void;
7172
}

types/test/options-test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ Vue.component('component-with-scoped-slot', {
196196
Vue.component('functional-component', {
197197
props: ['prop'],
198198
functional: true,
199+
inject: ['foo'],
199200
render(createElement, context) {
200201
context.props;
201202
context.children;
@@ -206,6 +207,14 @@ Vue.component('functional-component', {
206207
}
207208
} as FunctionalComponentOptions);
208209

210+
Vue.component('functional-component-object-inject', {
211+
functional: true,
212+
inject: {
213+
foo: 'bar',
214+
baz: Symbol()
215+
}
216+
})
217+
209218
Vue.component("async-component", ((resolve, reject) => {
210219
setTimeout(() => {
211220
resolve(Vue.component("component"));

types/test/tsconfig.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
"compilerOptions": {
33
"target": "es5",
44
"lib": [
5-
"es5",
65
"dom",
7-
"es2015.promise",
8-
"es2015.core"
6+
"es2015"
97
],
108
"module": "commonjs",
119
"noImplicitAny": true,

0 commit comments

Comments
 (0)