Closed kormic closed 2 years ago
This looks good! I know other libraries like RxJS and axios use this pattern and I've found it to be pretty useful.
I wonder if we can clean up the generic a bit when returnArgumentsArray
is true
. Rather than the developer having to remember to correctly type the tuple, we could provide a helper type like
type ArgumentsArray<T> = [ data: T[], fields: FieldInfo[], query: Query<T> ];
Then the developer only has to write
connection.query<ArgumentsArray<Employee>>('select * from employees limit 0, 10')
rather than
connection.query<[data: Employee[], fields: FieldInfo[], query: Query<Employee>]>('select * from employees limit 0, 10')
@move-zig yes sure, that makes sense!
Edit: this way there is no need to re-export the type FieldInfo
Thank you both @kormic and @move-zig for your work on this!
Published as 5.2.0
Improve typings. Use
Generics
so you can define the result of the promiseAdd a typescript example to demonstrate how you can use it with typescript