Tool for widening literal types ? #339
Unanswered
stefaanMLB
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Does ts-belt provide a tool to widen literal types ?
I currently have the code below. The get function extracts a configuration value out of an object with the option to pass a default value. When a default value is passed, I want the
getfunction to return the same type like the default parameter. Problem is that without theWiden<T>conditional type,getwill return a literal type (eg3000instead ofnumberorhostinstead ofstring) which will causes havoc in subsequent code.However, I don't like the
Widen<T>type definition at all and have been searching the web for alternatives. This repository seems to be the place to find this kind of utility. I could't find aWidenfunction ints-toolbelt, can ts-toolbelt be used for what I'm trying to do ?Beta Was this translation helpful? Give feedback.
All reactions