-
Notifications
You must be signed in to change notification settings - Fork 4
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
Upgrade to TS 2.8 #342
Upgrade to TS 2.8 #342
Conversation
Codecov Report
@@ Coverage Diff @@
## master #342 +/- ##
=========================================
Coverage ? 80.19%
=========================================
Files ? 90
Lines ? 919
Branches ? 113
=========================================
Hits ? 737
Misses ? 126
Partials ? 56
Continue to review full report at Codecov.
|
Hmm, I thought I disabled codecov comments 🤔 Anyway, here are the built-in conditional types that will be available in TS 2.8: microsoft/TypeScript#21847 |
Dude, this is awesome and just in time. Yesterday I was googling for "typescript how to remove null from type" and now I have my answer! |
Yep! Conditional types are very powerful! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
TypeScript 2.8 has a pretty cool feature, called Conditional Types, that allows us to do type-level programming, including things like:
Exclude<T, U>
type UnboxPromise<T> = T extends Promise<infer R> ? R : T
ReturnType<T>
.null
andundefined
from types, with the new built-inNonNullable<T>
.NonNullable
is particularly useful for us because we can get rid of non-null assertions in components that consume API queries that could possibly have anull
value. See the diff to get an idea of how this could simplify our types.Not merging this for now because:
typescript-eslint-parser
is failing on the newinfer R
andT extends R ? ...
syntax.