-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
API to understand if component object has props #4649
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
Comments
If the goal of this is purely to avoid showing a runtime warning (and isn't needed for other functionality) I think we should try to consider other ways of dealing with the root issue. See also #4652, which has been opened for just this concern. |
Thanks a lot for the answer. I understand your point and yes, at least as of now, the issue is purely related to #4652 (can’t exclude that others will find different uses in the future, however). |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Nope |
I'd appreciate the requested solution as well, but indeed the root issue is the console warning during runtime, which make development a less joyful experience. |
We removed the development warning from Svelte 5 (and possibly 4? can't remember) which solves the root issue — will close this |
Is your feature request related to a problem? Please describe.
Assume that
component
is a variable that contains a Svelte component class. For example:It would be useful to have an API to get details on what props
component
exposes.The reason for this is something that has appeared in svelte-spa-router recently. Starting with a recent version of Svelte, when using:
If the class of
component
does not export any params/props, Svelte now shows a warning.However, I don't believe there's a way to know if
component
has props. I have found a workaround in the router, but that was not always ideal and has caused a couple of issues to users too.Describe the solution you'd like
Would be great if component classes could export a list of properties (without their value). So, something like
component.props
being an array with the list of props exported.How important is this feature to you?
After finding a workaround, some users of svelte-spa-router have been impacted with annoyances caused by this. For example ItalyPaleAle/svelte-spa-router#102
A better solution would require the upstream Svelte project to export that property.
The text was updated successfully, but these errors were encountered: