From 7a6c70c4f29aeac346aa66a12b540845c87e6caa Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Fri, 20 Dec 2019 00:20:11 -0100 Subject: [PATCH] mgr/dashboard: Enable noImplicitThis TS compiler option Fixes: https://tracker.ceph.com/issues/43525 Signed-off-by: Tiago Melo --- .../nfs-form-client/nfs-form-client.component.spec.ts | 2 +- .../frontend/src/app/shared/decorators/cd-encode.ts | 4 ++-- .../app/shared/services/api-interceptor.service.ts | 11 ++++++++--- src/pybind/mgr/dashboard/frontend/tsconfig.json | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form-client/nfs-form-client.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form-client/nfs-form-client.component.spec.ts index 3c8e0bb502de7..1a5b2939003fc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form-client/nfs-form-client.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form-client/nfs-form-client.component.spec.ts @@ -23,7 +23,7 @@ describe('NfsFormClientComponent', () => { const formBuilder = TestBed.get(CdFormBuilder); component = fixture.componentInstance; - component.form = this.nfsForm = new CdFormGroup({ + component.form = new CdFormGroup({ access_type: new FormControl(''), clients: formBuilder.array([]), squash: new FormControl('') diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts index 744cd6a52fc14..a4aa06c244514 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts @@ -12,9 +12,9 @@ import * as _ from 'lodash'; export function cdEncode(...args: any[]): any { switch (args.length) { case 1: - return encodeClass.apply(this, args); + return encodeClass.apply(undefined, args); case 3: - return encodeMethod.apply(this, args); + return encodeMethod.apply(undefined, args); default: throw new Error(); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts index 374f863717dac..f93cffc5ec52c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts @@ -18,6 +18,11 @@ import { FinishedTask } from '../models/finished-task'; import { AuthStorageService } from './auth-storage.service'; import { NotificationService } from './notification.service'; +export class CdHttpErrorResponse extends HttpErrorResponse { + preventDefault: Function; + ignoreStatusCode: Function; +} + @Injectable({ providedIn: 'root' }) @@ -30,7 +35,7 @@ export class ApiInterceptorService implements HttpInterceptor { intercept(request: HttpRequest, next: HttpHandler): Observable> { return next.handle(request).pipe( - catchError((resp) => { + catchError((resp: CdHttpErrorResponse) => { if (resp instanceof HttpErrorResponse) { let timeoutId: number; switch (resp.status) { @@ -67,7 +72,7 @@ export class ApiInterceptorService implements HttpInterceptor { * preventDefault method defined). If called, it will prevent a * notification to be shown. */ - resp['preventDefault'] = () => { + resp.preventDefault = () => { this.notificationService.cancel(timeoutId); }; @@ -75,7 +80,7 @@ export class ApiInterceptorService implements HttpInterceptor { * If called, it will prevent a notification for the specific status code. * @param {number} status The status code to be ignored. */ - resp['ignoreStatusCode'] = function(status: number) { + resp.ignoreStatusCode = function(status: number) { if (this.status === status) { this.preventDefault(); } diff --git a/src/pybind/mgr/dashboard/frontend/tsconfig.json b/src/pybind/mgr/dashboard/frontend/tsconfig.json index cba66a1cc38ff..920370ad7eabb 100644 --- a/src/pybind/mgr/dashboard/frontend/tsconfig.json +++ b/src/pybind/mgr/dashboard/frontend/tsconfig.json @@ -13,6 +13,7 @@ "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, + "noImplicitThis": true, "target": "es2015", "typeRoots": [ "node_modules/@types" -- 2.39.5