antfu / reactivue

🙊 Use Vue Composition API in React components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

createSetup optional props type error

sibbng opened this issue · comments

https://github.com/antfu/reactivue/blob/master/examples/react-ts-vite/src/basic/createSetup.tsx#L9

This line throws this type error.

Argument of type '(props: Props) => { counter: Ref<number>; doubled: ComputedRef<number>; inc: () => number; }' is not assignable to parameter of type '(props?: Props | undefined) => { counter: Ref<number>; doubled: ComputedRef<number>; inc: () => number; }'.
  Types of parameters 'props' and 'props' are incompatible.
    Type 'Props | undefined' is not assignable to type 'Props'.
      Type 'undefined' is not assignable to type 'Props'.

Related PR #7

I am not sure whether we should solve this issue on the user side or the library side.

Hi, @antfu

I look at #7 litte bit. As far as I understand, the issue here is just the useSetup's argument name conflicts with the type name. Making createSetup's props type optional on callbacks should be totally unnecessary. Isn't it?