Skip to content

Commit 81e6137

Browse files
authored
Fix typescript linter errors (#7078)
## Motivation for features / changes Fix linter errors in test files to keep the codebase compliant with current TypeScript and tslint rules in internal build. ## Technical description of changes Cast `spyOn(store, 'dispatch') to jasmine.Spy` across 18 test files to satisfy `NgRx` dispatch overload signatures. Updated `throwError to factory form throwError(() => new Error(...))` per RxJS 7 requirements. Added `tslint:disable-next-line:enforce-name-casing` suppressions for snake_case keys that mirror backend API contracts.
1 parent 8e7bbc6 commit 81e6137

18 files changed

Lines changed: 83 additions & 40 deletions

File tree

tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/effects/debugger_effects_test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,12 @@ describe('Debugger effects', () => {
401401
}).compileComponents();
402402

403403
store = TestBed.inject<Store<State>>(Store) as MockStore<State>;
404-
dispatchSpy = spyOn(store, 'dispatch').and.callFake((action: Action) => {
405-
dispatchedActions.push(action);
406-
});
404+
// Cast to jasmine.Spy for compatibility between NgRx dispatch signature overloads.
405+
dispatchSpy = (spyOn(store, 'dispatch') as jasmine.Spy).and.callFake(
406+
(action: Action) => {
407+
dispatchedActions.push(action);
408+
}
409+
);
407410
store.overrideSelector(getActivePlugin, '');
408411
});
409412

@@ -436,6 +439,7 @@ describe('Debugger effects', () => {
436439
begin: number,
437440
end: number,
438441
alertsResponse: AlertsResponse,
442+
// tslint:disable-next-line:enforce-name-casing
439443
alert_type?: string
440444
) {
441445
if (alert_type === undefined) {
@@ -1403,6 +1407,7 @@ describe('Debugger effects', () => {
14031407
},
14041408
begin: 0,
14051409
end: 2,
1410+
// tslint:disable-next-line:enforce-name-casing
14061411
alert_type: AlertType.INF_NAN_ALERT,
14071412
per_type_alert_limit: 1000,
14081413
alerts: [alert0, alert1],
@@ -1657,7 +1662,9 @@ describe('Debugger effects', () => {
16571662
.withArgs(runId, fileIndex)
16581663
.and.returnValue(
16591664
of({
1665+
// tslint:disable-next-line:enforce-name-casing
16601666
host_name: hostName,
1667+
// tslint:disable-next-line:enforce-name-casing
16611668
file_path: filePath,
16621669
lines,
16631670
})

tensorboard/webapp/alert/alert_action_test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ describe('alert_effects', () => {
5959

6060
store = TestBed.inject<Store<State>>(Store) as MockStore<State>;
6161
recordedActions = [];
62-
spyOn(store, 'dispatch').and.callFake((action: Action) => {
62+
// Cast to jasmine.Spy for compatibility between NgRx dispatch signature overloads.
63+
(spyOn(store, 'dispatch') as jasmine.Spy).and.callFake((action: Action) => {
6364
recordedActions.push(action);
6465
});
6566
});

tensorboard/webapp/alert/views/alert_snackbar_test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ describe('alert snackbar', () => {
5656
}).compileComponents();
5757
store = TestBed.inject<Store<State>>(Store) as MockStore<State>;
5858
recordedActions = [];
59-
spyOn(store, 'dispatch').and.callFake((action: Action) => {
59+
// Cast to jasmine.Spy for compatibility between NgRx dispatch signature overloads.
60+
(spyOn(store, 'dispatch') as jasmine.Spy).and.callFake((action: Action) => {
6061
recordedActions.push(action);
6162
});
6263
overlayContainer = TestBed.inject(OverlayContainer);

tensorboard/webapp/app_routing/effects/app_routing_effects_test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ describe('app_routing_effects', () => {
243243
store.overrideSelector(getRehydratedDeepLinks, []);
244244
actualActions = [];
245245

246-
spyOn(store, 'dispatch').and.callFake((action: Action) => {
246+
// Cast to jasmine.Spy for compatibility between NgRx dispatch signature overloads.
247+
(spyOn(store, 'dispatch') as jasmine.Spy).and.callFake((action: Action) => {
247248
actualActions.push(action);
248249
});
249250

tensorboard/webapp/app_routing/views/router_link_test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ describe('router_link', () => {
8181
AppRootProvider
8282
) as TestableAppRootProvider;
8383

84-
spyOn(store, 'dispatch').and.callFake((action: Action) => {
84+
// Cast to jasmine.Spy for compatibility between NgRx dispatch signature overloads.
85+
(spyOn(store, 'dispatch') as jasmine.Spy).and.callFake((action: Action) => {
8586
actualDispatches.push(action);
8687
});
8788
});

tensorboard/webapp/core/effects/core_effects_test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ describe('core_effects', () => {
111111
store = TestBed.inject<Store<State>>(Store) as MockStore<State>;
112112

113113
recordedActions = [];
114-
spyOn(store, 'dispatch').and.callFake((action: Action) => {
114+
// Cast to jasmine.Spy for compatibility between NgRx dispatch signature overloads.
115+
(spyOn(store, 'dispatch') as jasmine.Spy).and.callFake((action: Action) => {
115116
recordedActions.push(action);
116117
});
117118

tensorboard/webapp/core/views/layout_test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ describe('layout test', () => {
8888

8989
dispatchedActions = [];
9090
store = TestBed.inject<Store<State>>(Store) as MockStore<State>;
91-
spyOn(store, 'dispatch').and.callFake((action: Action) => {
91+
// Cast to jasmine.Spy for compatibility between NgRx dispatch signature overloads.
92+
(spyOn(store, 'dispatch') as jasmine.Spy).and.callFake((action: Action) => {
9293
dispatchedActions.push(action);
9394
});
9495
store.overrideSelector(getSideBarWidthInPercent, 10);

tensorboard/webapp/header/dark_mode_toggle_test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ describe('dark mode toggle test', () => {
5050
store.overrideSelector(getEnableDarkModeOverride, null);
5151

5252
dispatchedActions = [];
53-
spyOn(store, 'dispatch').and.callFake((action: Action) => {
53+
// Cast to jasmine.Spy for compatibility between NgRx dispatch signature overloads.
54+
(spyOn(store, 'dispatch') as jasmine.Spy).and.callFake((action: Action) => {
5455
dispatchedActions.push(action);
5556
});
5657

tensorboard/webapp/hparams/_redux/hparams_effects_test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ describe('hparams effects', () => {
6565
store = TestBed.inject<Store<State>>(Store) as MockStore<State>;
6666

6767
actualActions = [];
68-
dispatchSpy = spyOn(store, 'dispatch').and.callFake((action: Action) => {
69-
actualActions.push(action);
70-
});
68+
// Cast to jasmine.Spy for compatibility between NgRx dispatch signature overloads.
69+
dispatchSpy = (spyOn(store, 'dispatch') as jasmine.Spy).and.callFake(
70+
(action: Action) => {
71+
actualActions.push(action);
72+
}
73+
);
7174

7275
effects = TestBed.inject(HparamsEffects);
7376
dataSource = TestBed.inject(

tensorboard/webapp/metrics/effects/metrics_effects_test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ describe('metrics effects', () => {
8585
}).compileComponents();
8686

8787
store = TestBed.inject<Store<State>>(Store) as MockStore<State>;
88-
spyOn(store, 'dispatch').and.callFake((action: Action) => {
88+
// Cast to jasmine.Spy for compatibility between NgRx dispatch signature overloads.
89+
(spyOn(store, 'dispatch') as jasmine.Spy).and.callFake((action: Action) => {
8990
actualActions.push(action);
9091
});
9192
effects = TestBed.inject(MetricsEffects);

0 commit comments

Comments
 (0)