Skip to content
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

In the setup, the referenced component reports an error #416

Closed
anncwb opened this issue Jun 29, 2020 · 8 comments
Closed

In the setup, the referenced component reports an error #416

anncwb opened this issue Jun 29, 2020 · 8 comments
Labels

Comments

@anncwb
Copy link

anncwb commented Jun 29, 2020

// component A

export default defineComponent({
    setup() {
      return ()=><BasicEmpty />;
    }, 
  });

// component BasicEmpty 

export default defineComponent({
  props: {
    description: {
      type: String,
      default: 'not data', 
    },
    image: {
      type: String,
      default: emptySrc,
    },
  },
  setup(props) {
    return () => (
      <Empty
        {...{
          props,
        }}
      />
    );
  },
});

error log

No overload matches this call.
  Overload 1 of 3, '(options?: ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never> | undefined): object & Record<never, any> & ... 6 more ... & ExtractComputedReturns<...>', gave the following error.
    Type '{ image: string; }' is not assignable to type 'Record<string, any> & Readonly<{ description: string; image: string; } & {}>'.
      Property 'description' is missing in type '{ image: string; }' but required in type 'Readonly<{ description: string; image: string; } & {}>'.
  Overload 2 of 3, '(options?: ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object> | undefined): object & Record<never, any> & ... 6 more ... & ExtractComputedReturns<...>', gave the following error.
    Type '{ image: string; }' is not assignable to type 'Record<string, any> & Readonly<{ description: string; image: string; } & {}>'.
      Property 'description' is missing in type '{ image: string; }' but required in type 'Readonly<{ description: string; image: string; } & {}>'.
  Overload 3 of 3, '(options?: ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> | undefined): object & ... 7 more ... & ExtractComputedReturns<...>', gave the following error.
    Type '{ image: string; }' is not assignable to type 'Record<string, any> & Readonly<{ description: string; image: string; } & {}>'.
      Property 'description' is missing in type '{ image: string; }' but required in type 'Readonly<{ description: string; image: string; } & {}>'.
@anncwb
Copy link
Author

anncwb commented Jun 29, 2020

0.63 does not have this problem. Upgrade to 0.67 appears

@anncwb
Copy link
Author

anncwb commented Jun 29, 2020

props should not be mandatory

@anncwb
Copy link
Author

anncwb commented Jun 29, 2020

@antfu please help me

@antfu
Copy link
Member

antfu commented Jun 29, 2020

We don't have official JSX support for @vue/composition-api yet (which is planned, vuejs/jsx-vue2#76). We have updated the typing of defineComponent recently to align with vue-next. For the issue you are facing, I suggest you open an issue in the jsx support plugin repo first (guess you are using https://github.com/luwanquan/babel-preset-vca-jsx)

@anncwb
Copy link
Author

anncwb commented Jun 30, 2020

There should be no relationship with the vca-jsx plugin,
I think it is related to the following

declare global {
 
  namespace JSX {
    // @ts-ignore
    interface Element extends VNode {}
    // @ts-ignore
    interface ElementClass extends ComponentRenderProxy {}
    interface ElementAttributesProperty {
      $props?: any; 
    }
    interface IntrinsicElements {
      [elem: string]: any;
    }
  }
}

@antfu antfu added the jsx label Jun 30, 2020
@anncwb
Copy link
Author

anncwb commented Jun 30, 2020

@antfu May I ask what time jsx can support

@anncwb
Copy link
Author

anncwb commented Jun 30, 2020

Forgive me for my bad English, the translation depends on Google

@anncwb
Copy link
Author

anncwb commented Jul 2, 2020

Adding as PropOptions to every props solved my problem

@anncwb anncwb closed this as completed Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants