Skip to content

Commit

Permalink
fix(types): add inject option in functional component options type (v…
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsn authored and hefeng committed Jan 25, 2019
1 parent 5e91fa5 commit b7a905b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions types/test/options-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
Expand Down
4 changes: 1 addition & 3 deletions types/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
"compilerOptions": {
"target": "es5",
"lib": [
"es5",
"dom",
"es2015.promise",
"es2015.core"
"es2015"
],
"module": "commonjs",
"noImplicitAny": true,
Expand Down

0 comments on commit b7a905b

Please sign in to comment.