-
Notifications
You must be signed in to change notification settings - Fork 19
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
Use TypeScript assert condition
signature for invariant(condition, message)
#12
Conversation
This PR is required if we want to solve apollographql/apollo-client#6073 |
@PowerKiKi Do you know if using this syntax is safe for applications that use an older version of TypeScript? |
It is not, I broke some people on an older version of TS by adding this to Jest. Seems worth it to make a breaking change though, so |
Correct, we now require TypeScript 3.7. I have no idea how tests did not fail in my local install... I rebased and forced push a new commit including versions increase. I am wondering whether this should also be declared as peerDependencies in PS: also notice that I simplified the README, as it is no longer true. And we could argue whether |
5a85bed
to
a0ed820
Compare
@benjamn would you have time to have another look at this? |
@benjamn it seems you were interested in this PR earlier this year. And I fixed the issues raised in the meantime. I still think it would add a lot of value to this lib. Would you have time to review/merge it ? |
@PowerKiKi Thanks for the ping. I am checking with my team (@hwillson and a few others) to see if we can raise the minimum to 3.7 at this point, and I will report back (hopefully today). |
This allow TypeScript to know that an assertion was made and that types can be narrowed down after a call to `invariant()`. For more details see microsoft/TypeScript#32695
assert condition
signature for invariant(condition, message)
🎉 |
This allow TypeScript to know that an assertion was made and that
types can be narrowed down after a call to
invariant()
.For more details see microsoft/TypeScript#32695