diff --git a/src/apps/rednatco/api-impl.ts b/src/apps/rednatco/api-impl.ts index b559ba13ce40c579f7a70d7d972504e93bf32c6b..4a4dafce40a1b51929171976addddea744d82de9 100644 --- a/src/apps/rednatco/api-impl.ts +++ b/src/apps/rednatco/api-impl.ts @@ -39,8 +39,8 @@ export class ReDNATCOMspApiImpl implements ReDNATCOMspApi.Object { this.target!.loadStructure(data, type); } - query(type: ReDNATCOMspApi.Queries.Type): ReDNATCOMspApi.Response { + query<T extends ReDNATCOMspApi.Queries.Type>(type: T): ReDNATCOMspApi.ResponseTypes[T] { this.check(); - return this.target!.apiQuery(type); + return this.target!.apiQuery(type) as ReDNATCOMspApi.ResponseTypes[T]; } } diff --git a/src/apps/rednatco/api.ts b/src/apps/rednatco/api.ts index b53d578014a28788e487d24c8ce0765e588e92fd..8ccf9a541559c435a7459ec1ea4f28bfb2024990 100644 --- a/src/apps/rednatco/api.ts +++ b/src/apps/rednatco/api.ts @@ -106,6 +106,10 @@ export namespace ReDNATCOMspApi { } } export type Response = Queries.CurrentFilter|Queries.SelectedStep; + export type ResponseTypes = { + 'current-filter': Queries.CurrentFilter, + 'selected-step': Queries.SelectedStep, + } export interface Object { command: (cmd: Command) => void; @@ -113,6 +117,6 @@ export namespace ReDNATCOMspApi { init: (elemId: string, onEvent?: (evt: Event) => void) => void; isReady: () => boolean; loadStructure: (data: string, type: 'cif'|'pdb') => void; - query: (type: Queries.Type) => Response; + query: <T extends Queries.Type>(type: T) => ResponseTypes[T]; } }