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

Make props argument optional #590

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

duckradu
Copy link

The signature for the Directive doesn't allow it to be used as a ref as shown in the docs. If the props are optional then the function signature matches.

image

Copy link

changeset-bot bot commented Mar 24, 2024

⚠️ No Changeset found

Latest commit: c538e02

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@thetarnav
Copy link
Member

I don’t think you’re using the type correctly.
ref is not a directive.

@duckradu
Copy link
Author

I was following the example from the docs - https://primitives.solidjs.community/package/pagination#createinfinitescroll

@thetarnav
Copy link
Member

ah nvm I get it
I have to think about it
Making it optional hurts the proper usage

@thetarnav
Copy link
Member

this? use:infiniteScrollLoader?

@duckradu
Copy link
Author

The docs show that it can be used both as a directive and ref:

image

(feel free to dm me on discord if it's easier to chat there)

@thetarnav
Copy link
Member

It looks like it shouldn’t be typed as a directive if it is meant to be used with both ref and as a directive. because it just doesn’t use the second arg at all.

@duckradu
Copy link
Author

duckradu commented Mar 24, 2024

Would a new custom type be okay in that case? Something like ElementInstance or idk, which basically has the signature of a ref, but could be used as a Directive as well when the props are not relevant

@thetarnav
Copy link
Member

no need to make it a generic helper. createInfiniteScroll just should be typed correctly.

@duckradu
Copy link
Author

Something like this?

image

@thetarnav
Copy link
Member

yes although there is no need in making it generic
I think loader: (el: Element) => void would be enough

@duckradu
Copy link
Author

Done! Want me to update this PR or should I just close it?

@thetarnav
Copy link
Member

It seems that this PR is about something completely different now?
Can you make a separate PR for the changes that are changing the API, and leave only the type-fix here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants