Fix typing to allow different return values per query #48
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.
The current typing requires one to define the return type for all queries when initializing AthenaExpress.
As one wants to execute different queries with different return types they would have to create new instances of AthenaExpress or ignore the typing (using
as
or@ts-ignore
).By moving the generic parameter from the class to the
query
method, the expected return type can be set for every call seperatly.I also added a default parameter
any
so one does not need to define the return type if they do not with to do so or do not know the exact typing, while still being able to use the general typing ofQueryResult
.This change would require all existing typescript users to update their usage. It would be possible for me to add this in a backwards compatible way if requested.
Example in code: