Open Emiyaaaaa opened 3 months ago
One could also do:
type SimplifyItem = SimplifyDeep<Omit<Item, 'color'>> & Pick<Item, 'color'>;
And if one wants a helper to keep it a bit shorter one could do something like this in ones types:
type SimplifyDeepExcept<A, B extends keyof A> = SimplifyDeep<Omit<A,B>> & Pick<A, B>;
Is it common that that needs to exclude something like THREE.Color
at an unknown location in an object?
Related: https://github.com/sindresorhus/type-fest/issues/719
Kind of requests the opposite: https://github.com/sindresorhus/type-fest/issues/860 (Kind of request an { only: string }
rather than an { exclude: string }
)
type SimplifyItem = SimplifyDeep<Omit<Item, 'color'>> & Pick<Item, 'color'>;
My case is more complicated. THREE.Color
is deep in nested object, and must used type to exclude not key, because key could be 'lineColor', 'pointColor' or other in my scene
This proposal makes sense to me.
Sorry, I found I could use ConditionalSimplifyDeep<Item, THREE.Color, object>
instead, but other deep type also need this feature.
Look at this scene
I have a type
Item
that wrapped with some util type, and I want get a simplifyItem
, like:but actual rsult is:
so maybe we can add a exclude type option ( or named
keep
) on Deep type like:It can also resolve scene conflicts between users, such as one want recursive into
HTMLElemet
, anther one want keepHTMLElemet
Related comment: https://github.com/sindresorhus/type-fest/issues/651#issuecomment-1803324362 Related issue: #651
Upvote & Fund