You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which, aside from the fact that it's simplified because the array should not be nested and the booleans should only be nested, does not work, because one cannot use a function (the Callback variant in this example) type here.
Would it be possible to add that? Since you can check that easily with typeof == "function".
Thanks, so it looks like a case where one wants to construct values rather than doing pattern matching on.
While the internal implementation of material UI is the one that does "pattern matching", in the sense of detecting different shapes used.
Activity
cristianoc commentedon May 31, 2023
Do you have references to example TS code that uses that?
Just curious, not important. The description is already clear.
fhammerschmidt commentedon May 31, 2023
Yes, here: https://mui.com/system/getting-started/the-sx-prop/#callback-values
cristianoc commentedon May 31, 2023
Thanks, so it looks like a case where one wants to construct values rather than doing pattern matching on.
While the internal implementation of material UI is the one that does "pattern matching", in the sense of detecting different shapes used.
fhammerschmidt commentedon May 31, 2023
That is true. Looks like in this case a bunch of externals with
%identityis still the way to go.However, I still wonder if it would be a useful addition in other cases.
zth commentedon May 31, 2023
This pattern, providing either an object or a function to produce that object, is quite common in TS I'd say.
cknitt commentedon May 31, 2023
instead of
would be nice, too. (Wasn't there a discussion about that somewhere else? Can't find the issue.)
Add support for functions in untagged variants.
zth commentedon May 31, 2023
Here: #6231
Add support for functions in untagged variants. (#6279)