solid icon indicating copy to clipboard operation
solid copied to clipboard

optional props typescript types error & props bug

Open ptrtorain opened this issue 1 year ago • 0 comments

Describe the bug

If all of my props are optional in a type, I shouldn't need to pass them in a hook, but I'm getting an error:

Expected 1 arguments, but got 0.typescript(2554) useHook.tsx(1, 25): An argument matching this binding pattern was not provided.

Moreover, if you've passed inline params, they won't work - you'll get undefined. However, you can fix everything above if you pass {} in props. I think SolidJS should do this by itself because it causes significant issues when building a library for it.

Your Example Website or App

https://codesandbox.io/p/devbox/still-lake-forked-9qsvdf?file=%2Fsrc%2FApp.tsx%3A5%2C29

Steps to Reproduce the Bug or Issue

  1. Go to the link
  2. Pass { } to useHook
  3. Manually press refresh button in the IDE browser
  4. You'll see the text

Expected behavior

If all of my props are optional, I shouldn't get an "Expected N arguments" TypeScript error, just like in React. The developer shouldn't need to manually pass {} in props to make inline params work (they are undefined right now).

Screenshots or Videos

No response

Platform

  • OS: [Windows,]
  • Browser: [e.g. Firefox,]
  • Version: [91.1]

Additional context

No response

ptrtorain avatar Jun 29 '24 13:06 ptrtorain