Skip to content

fix: add inject option in functional component options type #6530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion types/options.d.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 9 additions & 0 deletions types/test/options-test.ts
Original file line number Diff line number Diff line change
@@ -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"));
4 changes: 1 addition & 3 deletions types/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -2,10 +2,8 @@
"compilerOptions": {
"target": "es5",
"lib": [
"es5",
"dom",
"es2015.promise",
"es2015.core"
"es2015"
],
"module": "commonjs",
"noImplicitAny": true,