From cd7f2c208a3af8e491ee700404408ee74bea946f Mon Sep 17 00:00:00 2001 From: Asier Illarramendi Date: Thu, 1 Dec 2022 11:55:52 +0100 Subject: [PATCH 1/2] Update `Type` so it's the same as in Angular/Nest `unknown` was giving issues, `any` is necessary in this case. --- packages/core/src/helpers/types.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/src/helpers/types.ts b/packages/core/src/helpers/types.ts index d67c90a6..ead26bb2 100644 --- a/packages/core/src/helpers/types.ts +++ b/packages/core/src/helpers/types.ts @@ -3,7 +3,9 @@ * @see https://stackoverflow.com/a/52183279/379923 */ export interface Type extends Function { - new (...args: unknown[]): T; + // In this case, it must be `any`. Using `unknown` give compile errors. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + new (...args: any[]): T; } /** From 1df4e8c754e701fb54b97f33a41f7db34c6c9747 Mon Sep 17 00:00:00 2001 From: Asier Illarramendi Date: Thu, 1 Dec 2022 11:56:58 +0100 Subject: [PATCH 2/2] Relax `HttpRequestBuilder` return types, just match to the generic --- packages/angular/src/http-request.builder.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/angular/src/http-request.builder.ts b/packages/angular/src/http-request.builder.ts index be49fece..df8a6a40 100644 --- a/packages/angular/src/http-request.builder.ts +++ b/packages/angular/src/http-request.builder.ts @@ -62,7 +62,11 @@ export class HttpRequestBuilder { return mapper.map(responseItem); } - private mapResponse(res: HttpResponse): T | T[] | undefined { + // HACK: This is problematic but it's the best we can do right now. + // Let's assume that `T` equals to the return type of this `mapResponse`. + // See: https://app.asana.com/0/1109863238977521/1203450043003508/f + // eslint-disable-next-line @typescript-eslint/no-explicit-any + private mapResponse(res: HttpResponse): any { if (!res.body) { return undefined; } @@ -80,19 +84,19 @@ export class HttpRequestBuilder { return this.mapItem(res.body); } - public get(): Observable { + public get(): Observable { return this.http .get(this.urlBuilder.getUrl(), { observe: 'response', headers: this.headers }) .pipe(map((res) => this.mapResponse(res))); } - public post(): Observable { + public post(): Observable { return this.http .post(this.urlBuilder.getUrl(), this.body, { observe: 'response', headers: this.headers }) .pipe(map((res) => this.mapResponse(res))); } - public put(): Observable { + public put(): Observable { return this.http .put(this.urlBuilder.getUrl(), this.body, { observe: 'response', headers: this.headers }) .pipe(map((res) => this.mapResponse(res)));