🏷️ fix(strongly-typed) allow use of generic helpers #173
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.
Fixes #170
At the moment it's impossible to create generic helper functions to deal with
TypedContainer
:This is because of the
Synchronous
type that guards against calling.get()
onPromise
bindings. Under the hood, this type is a mapped type, which doesn't work well with generics (by design).Rather than drop this guard all together, this change aims to strike a balance by removing the
Synchronous
mapped type, and instead changing the return type of synchronousget()
methods to benever
if the binding is aPromise
.This won't error as obviously or as immediately as before, but will still at least flag to the developer semantically that this binding will never return a value (since it will throw), and should cause compilation errors if consumers try to do anything with the returned value.
In return, we gain the ability to use generic helper functions.