Upgrade to TS 2.8#342
Merged
Merged
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.
|
Contributor
Author
|
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 |
Contributor
|
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! |
Contributor
Author
|
Yep! Conditional types are very powerful! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 : TReturnType<T>.nullandundefinedfrom types, with the new built-inNonNullable<T>.NonNullableis particularly useful for us because we can get rid of non-null assertions in components that consume API queries that could possibly have anullvalue. See the diff to get an idea of how this could simplify our types.Not merging this for now because:
typescript-eslint-parseris failing on the newinfer RandT extends R ? ...syntax.