From b7a905be50121f97e9453ffac083f6550327b1d7 Mon Sep 17 00:00:00 2001 From: katashin Date: Wed, 13 Sep 2017 15:25:50 +0900 Subject: [PATCH] fix(types): add `inject` option in functional component options type (#6530) --- types/options.d.ts | 3 ++- types/test/options-test.ts | 9 +++++++++ types/test/tsconfig.json | 4 +--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/types/options.d.ts b/types/options.d.ts index 0de8e8f7de5..b28a228a6c8 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -47,7 +47,7 @@ export interface ComponentOptions { filters?: { [key: string]: Function }; provide?: Object | (() => Object); - inject?: { [key: string]: string | symbol } | Array; + inject?: { [key: string]: string | symbol } | string[]; model?: { prop?: string; @@ -66,6 +66,7 @@ export interface ComponentOptions { 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; } diff --git a/types/test/options-test.ts b/types/test/options-test.ts index 3f17b071a33..cbd5be1423f 100644 --- a/types/test/options-test.ts +++ b/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")); diff --git a/types/test/tsconfig.json b/types/test/tsconfig.json index 68aca8c1f1e..cbc565a7c53 100644 --- a/types/test/tsconfig.json +++ b/types/test/tsconfig.json @@ -2,10 +2,8 @@ "compilerOptions": { "target": "es5", "lib": [ - "es5", "dom", - "es2015.promise", - "es2015.core" + "es2015" ], "module": "commonjs", "noImplicitAny": true,