-
-
Notifications
You must be signed in to change notification settings - Fork 937
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
upgrade Show component - added prop checkObjectValues #2340
base: main
Are you sure you want to change the base?
Conversation
|
@davedbase you're also quite active on discord. What are your thoughts on this? |
That would be quite handy tbh. |
simplified types
So,...
|
This feels Solid Primitives area. As you have noted the implementation becomes more complicated as you try to do these checks. Generally I try avoid any base implementation that gets us into Stores because not every platform supports Proxies. It is unlikely a change like this happens in 1.x time period but I'm definitely interested in this area to understand the problems this solves and understand all the scenarios as we approach control flow improvements for 2.0. That being said it seems to have value today which is why I point to Solid Primitives: https://github.com/solidjs-community/solid-primitives |
Just pasting some comments from the SolidJack 2024 channel about this topic: |
First of all - this PR is open for discussion
Before adding changes, documentation, etc. I just wanted to get some feedback if this has a chance to be merged.
-- no breaking change --
Show will just behave as before when
checkObjectValues
is not set / true.Motivation: e.g.From Discord
Setting it to true will allow narrow the type of all values to NonNullable.
Imagine this case where you have a signal and store that relies in user input without initial values and you need to pass them to a child component which has strict non-null types.
With current Show typescript will complain that first and last might be undefined. So you either have to use the bang operator or use createMemo to narrow like
And pass it to Show which now correctly narrows to non-null types.
With the added prop you can just:
Summary
How did you test this change?