From 3587049d6a2456f15ab7988e99876b39c1f4b978 Mon Sep 17 00:00:00 2001 From: Evan Purkhiser Date: Thu, 14 May 2020 00:27:29 -0700 Subject: [PATCH] Be explicit about return types to avoid tsc complaints See https://github.com/microsoft/TypeScript/issues/9944 --- src/remotedb/index.ts | 2 +- src/remotedb/message/index.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/remotedb/index.ts b/src/remotedb/index.ts index c87f29a41..d04c02cd6 100644 --- a/src/remotedb/index.ts +++ b/src/remotedb/index.ts @@ -131,7 +131,7 @@ export class QueryInterface { /** * Make a query to the remote database connection. */ - async query(opts: QueryOpts) { + async query(opts: QueryOpts): Promise> { const {query, queryDescriptor, args} = opts; const conn = this.#conn; diff --git a/src/remotedb/message/index.ts b/src/remotedb/message/index.ts index 255ad1382..69ca4b348 100644 --- a/src/remotedb/message/index.ts +++ b/src/remotedb/message/index.ts @@ -55,6 +55,9 @@ type Options = { args: Field[]; }; +type ResponseType = T extends Response ? T : never; +type Data = ReturnType]>; + /** * Representation of a set of fields sequenced into a known message format. */ @@ -165,16 +168,13 @@ export class Message { * * Currently only supports representing response messages. */ - get data() { - type ResponseType = T extends Response ? T : never; - type Data = ReturnType; - - const type = this.type as ResponseType; + get data(): Data { + const type = this.type as ResponseType; if (!Object.values(Response).includes(type)) { throw new Error('Representation of non-responses is not currently supported'); } - return responseTransform[type](this.args) as Data; + return responseTransform[type](this.args) as Data; } }