-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: strengthen typings #148
Conversation
A typescript bump to |
Great PR @Lioness100, will review shortly. I noticed that Also, apologies for the CI not working. I'll move from Travis to GH Actions soon since Travis seems completely broken for this specific repo. |
Thanks! |
Published in 7.1.0! Thanks @Lioness100 |
Awesome! |
I thought the whole point of this library was to check if the variable existed in the "container" via the |
I'm not sure I understand your concern. My understanding is this package is not for asserting the type of the container, but for asserting the types of the containers properties. Furthermore, the typings change wasn't made so that the values could be inferred- you're right, that's what the existing functions are for. Instead, the typings are to assert that the names of the key inputted in This doesn't actually change anything for most people. The Also, if you don't like asserting the |
@Lioness100 It seems redundant to specify what properties I can call |
As shown in the original PR message - typos! If you want to get a variable If your code breaks by this change, you are given an opportunity to strengthen your types 🙂 isn't that the whole point of typescript? And again, if you don't want to strengthen your types, you can use |
I understand the use case. It's still redundant since you can always do something like |
I'm not sure what you mean by that |
An aspect of type safety is lost from this library because the
get
function isn't required to be a key of the container. For example:With
process.env
, it is common for typescript users to augment theProcessEnv
:However, this isn't currently producible with this library. To fix this, I edited the types to add a new
Container
generic inIEnv
to be used in theget()
function.I also removed the
PresentVariable
generic because it... wasn't actually used in the interface.