Просмотр исходного кода

fix(types): add `inject` option in functional component options type (#6530)

katashin 8 лет назад
Родитель
Сommit
1baa0a7884
3 измененных файлов с 12 добавлено и 4 удалено
  1. 2 1
      types/options.d.ts
  2. 9 0
      types/test/options-test.ts
  3. 1 3
      types/test/tsconfig.json

+ 2 - 1
types/options.d.ts

@@ -47,7 +47,7 @@ export interface ComponentOptions<V extends Vue> {
   filters?: { [key: string]: Function };
 
   provide?: Object | (() => Object);
-  inject?: { [key: string]: string | symbol } | Array<string>;
+  inject?: { [key: string]: string | symbol } | string[];
 
   model?: {
     prop?: string;
@@ -66,6 +66,7 @@ export interface ComponentOptions<V extends Vue> {
 export interface FunctionalComponentOptions {
   name?: string;
   props?: string[] | { [key: string]: PropOptions | Constructor | Constructor[] };
+  inject?: { [key: string]: string | symbol } | string[];
   functional: boolean;
   render(this: never, createElement: CreateElement, context: RenderContext): VNode | void;
 }

+ 9 - 0
types/test/options-test.ts

@@ -196,6 +196,7 @@ Vue.component('component-with-scoped-slot', {
 Vue.component('functional-component', {
   props: ['prop'],
   functional: true,
+  inject: ['foo'],
   render(createElement, context) {
     context.props;
     context.children;
@@ -206,6 +207,14 @@ Vue.component('functional-component', {
   }
 } as FunctionalComponentOptions);
 
+Vue.component('functional-component-object-inject', {
+  functional: true,
+  inject: {
+    foo: 'bar',
+    baz: Symbol()
+  }
+})
+
 Vue.component("async-component", ((resolve, reject) => {
   setTimeout(() => {
     resolve(Vue.component("component"));

+ 1 - 3
types/test/tsconfig.json

@@ -2,10 +2,8 @@
   "compilerOptions": {
     "target": "es5",
     "lib": [
-      "es5",
       "dom",
-      "es2015.promise",
-      "es2015.core"
+      "es2015"
     ],
     "module": "commonjs",
     "noImplicitAny": true,