]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Enable noImplicitThis TS compiler option
authorTiago Melo <tmelo@suse.com>
Fri, 20 Dec 2019 01:20:11 +0000 (00:20 -0100)
committerTiago Melo <tmelo@suse.com>
Fri, 31 Jan 2020 14:16:09 +0000 (13:16 -0100)
Fixes: https://tracker.ceph.com/issues/43525
Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form-client/nfs-form-client.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts
src/pybind/mgr/dashboard/frontend/tsconfig.json

index 3c8e0bb502de75e4914d6d2e6b97c50e24390a21..1a5b2939003fc1e007187ae9d9a6becca8520d39 100644 (file)
@@ -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('')
index 744cd6a52fc145134697756fb4cd103b9404d861..a4aa06c24451430a8f069fbf1b435ff107e6ecdd 100644 (file)
@@ -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();
   }
index 374f863717dac60790722334ccae46663456c8cc..f93cffc5ec52c941e5d613a645cea2fa631c5554 100644 (file)
@@ -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<any>, next: HttpHandler): Observable<HttpEvent<any>> {
     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();
             }
index cba66a1cc38ffe0280ff2b805628869da696fdff..920370ad7eabb82b1f7cef7c6515d04d7c187dd6 100644 (file)
@@ -13,6 +13,7 @@
     "noUnusedLocals": true,
     "noUnusedParameters": true,
     "noFallthroughCasesInSwitch": true,
+    "noImplicitThis": true,
     "target": "es2015",
     "typeRoots": [
       "node_modules/@types"