From c24dcfe4f5a58eed0b40765c5bb4dbc4f23a00a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Mon, 16 Nov 2020 18:34:59 +0100 Subject: [PATCH] Fix typing to allow different return values per query 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 of `QueryResult`. --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 6265b66..56c64a1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -38,11 +38,11 @@ declare module 'athena-express' { type OptionalQueryResultsInterface = Partial> & Pick, 'QueryExecutionId'>; type QueryResult = OptionalQueryResultsInterface; - type QueryFunc = (query: QueryObjectInterface|DirectQueryString|QueryExecutionId) => Promise>; + type QueryFunc = (query: QueryObjectInterface|DirectQueryString|QueryExecutionId) => Promise>; - class AthenaExpress { + class AthenaExpress { public new: (config: Partial) => any; - public query: QueryFunc; + public query: QueryFunc; constructor(config: Partial); } }