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
-
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
get
function to return the same type like the default parameter. Problem is that without theWiden<T>
conditional type,get
will return a literal type (eg3000
instead ofnumber
orhost
instead 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 aWiden
function ints-toolbelt
, can ts-toolbelt be used for what I'm trying to do ?Beta Was this translation helpful? Give feedback.
All reactions