Open devarsh-mavani-19 opened 2 months ago
I personally only use this with dynamic data, not typescript typed strings. I believe that if you want to implement correct typescript type inference, you probably need to re-implement the entire JS logic in pure TS somehow. I'm not sure how that could be possible.
PRs welcome.
Hey @mesqueeb
I have been an active user of this library across many projects. One problem faced is that the library doesn't retain the literal types. It converts everything to string. For example
Why this would be useful?
I have had situations where I want to use the value to index an object. and if the value is string then I have to typecast it explicitly. Example from above
of course simple thing to do is typecast it. But it would be great to have inbuilt type inference.
I am willing to contribute to this feature if you guys are open to outside contributions. and eventually, we can add this support to all case types. I am not sure how difficult it would be but I all ears to suggestions. maybe we can have a separate functions for more stricter types? please let me know what you think about this.