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
Using Object.Optional is very handy. But if you want to use the 'deep' option, it requires filling in the optional K parameter as well. For most cases where I want to use a deep-optional object, I'd like to use the default K = keyof T argument, so it's inconvenient to have to specify this parameter manually. Creating an alias for the 'deep' version of the command would allow people to leverage the nice defaults available.
Describe alternatives you've considered
I believe Typescript has discussed a feature where you could use _ in place of a generic parameter to accept the default value. This would let users write O.Optional<T, _, 'deep'> instead. However, I can no longer find the TS issue discussing this feature, so I don't know when or if it is expected to arrive.
Additionally, users could just create their own DeepOptional alias. But it has been nice to be able to consolidate many type aliases in a standard way under a single library like ts-toolbelt.
We should be able to copy the documentation for Object.Optional, adding a note that this method is an alias for Object.Optional<O,K, 'deep'> and functionality is the same.
Ah, that's definitely a lot better than having to duplicate the first type parameter. I think an alias could still be nice, but the any workaround does remove a lot of the need.
millsp
changed the title
Alias for "DeepOptional"
How not to provide the keys for "deep" types every time?
Dec 17, 2019
I'm marking this as resolved, as on of my goals is to provide a unified API for the type utilities (no duplicates). I feel like typing any is short enough not to create a new alias.
馃崺 Feature Request
Is your feature request related to a problem?
No.
Describe the solution you'd like
Using
Object.Optional
is very handy. But if you want to use the'deep'
option, it requires filling in the optionalK
parameter as well. For most cases where I want to use a deep-optional object, I'd like to use the defaultK = keyof T
argument, so it's inconvenient to have to specify this parameter manually. Creating an alias for the'deep'
version of the command would allow people to leverage the nice defaults available.Describe alternatives you've considered
I believe Typescript has discussed a feature where you could use
_
in place of a generic parameter to accept the default value. This would let users writeO.Optional<T, _, 'deep'>
instead. However, I can no longer find the TS issue discussing this feature, so I don't know when or if it is expected to arrive.Additionally, users could just create their own
DeepOptional
alias. But it has been nice to be able to consolidate many type aliases in a standard way under a single library like ts-toolbelt.Teachability, Documentation, Adoption, Migration Strategy
We should be able to copy the documentation for
Object.Optional
, adding a note that this method is an alias forObject.Optional<O,K, 'deep'>
and functionality is the same.Examples
The text was updated successfully, but these errors were encountered: