Remove few usages of any
Change-Id: I7bda9f50eabd90ca58232945e51c4a269feada45
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
index 98dddb7..79f029b 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
@@ -391,8 +391,7 @@
return this._getPatchSetWeblink(params);
default:
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- console.warn(`Unsupported weblink ${(params as any).type}!`);
- // TODO(TS): use assertNever(params.type)
+ assertNever(params, `Unsupported weblink ${(params as any).type}!`);
return [];
}
}
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-side-by-side.ts b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-side-by-side.ts
index bab447e..67f2dcb 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-side-by-side.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-side-by-side.ts
@@ -20,15 +20,14 @@
import {DiffInfo, DiffPreferencesInfo} from '../../../types/diff';
import {GrDiffLine, LineNumber} from '../gr-diff/gr-diff-line';
import {DiffViewMode, Side} from '../../../constants/constants';
+import {DiffLayer} from '../../../types/types';
export class GrDiffBuilderSideBySide extends GrDiffBuilder {
constructor(
diff: DiffInfo,
prefs: DiffPreferencesInfo,
outputEl: HTMLElement,
- // TODO(TS): Replace any by a layer interface.
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- readonly layers: any[] = [],
+ readonly layers: DiffLayer[] = [],
useNewContextControls = false
) {
super(diff, prefs, outputEl, layers, useNewContextControls);
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-unified.ts b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-unified.ts
index fb7f377..85af2ee 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-unified.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder-unified.ts
@@ -19,15 +19,14 @@
import {GrDiffGroup, GrDiffGroupType} from '../gr-diff/gr-diff-group';
import {DiffInfo, DiffPreferencesInfo} from '../../../types/diff';
import {DiffViewMode, Side} from '../../../constants/constants';
+import {DiffLayer} from '../../../types/types';
export class GrDiffBuilderUnified extends GrDiffBuilder {
constructor(
diff: DiffInfo,
prefs: DiffPreferencesInfo,
outputEl: HTMLElement,
- // TODO(TS): Replace any by a layer interface.
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- readonly layers: any[] = [],
+ readonly layers: DiffLayer[] = [],
useNewContextControls = false
) {
super(diff, prefs, outputEl, layers, useNewContextControls);
diff --git a/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts b/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts
index e8d87e6..ff6efe6 100644
--- a/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts
+++ b/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts
@@ -50,8 +50,7 @@
*/
@property({type: Object})
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- keyEventTarget: Record<string, any> = document.body;
+ keyEventTarget = document.body;
@property({type: Boolean})
positionBelow = false;
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts
index 2fc96ab..4fd7337 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts
@@ -125,13 +125,13 @@
)
);
});
- // TODO(TS): Should be a number, but TS thinks that is must be some weird
- // NodeJS.Timeout object.
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- let timeoutId: any;
+ let timeoutId: number;
const timeout = new Promise(
() =>
- (timeoutId = setTimeout(() => {
+ // specify window here so that TS pulls the correct setTimeout method
+ // if window is not specified, then the function is pulled from node
+ // and the return type is NodeJS.Timeout object
+ (timeoutId = window.setTimeout(() => {
console.warn(
'Timeout waiting for endpoint properties initialization: ' +
`plugin ${plugin.getPluginName()}, endpoint ${this.name}`
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.ts b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.ts
index d30d48d..b7c7b69 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.ts
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.ts
@@ -26,12 +26,11 @@
import {IronFitMixin} from '../../../mixins/iron-fit-mixin/iron-fit-mixin';
import {customElement, property, observe} from '@polymer/decorators';
import {IronFitBehavior} from '@polymer/iron-fit-behavior/iron-fit-behavior';
+import {GrCursorManager} from '../gr-cursor-manager/gr-cursor-manager';
-// TODO(TS): Update once GrCursorManager is upated
export interface GrAutocompleteDropdown {
$: {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- cursor: any;
+ cursor: GrCursorManager;
suggestions: Element;
};
}
@@ -116,7 +115,7 @@
}
getCurrentText() {
- return this.getCursorTarget().dataset['value'];
+ return this.getCursorTarget()?.dataset['value'] || '';
}
_handleUp(e: Event) {
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
index 860c38b..19430ac 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
@@ -424,15 +424,15 @@
return Promise.resolve();
}
if (!this._loadingPromise) {
- // TODO(TS): Should be a number, but TS thinks that is must be some weird
- // NodeJS.Timeout object.
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- let timerId: any;
+ // specify window here so that TS pulls the correct setTimeout method
+ // if window is not specified, then the function is pulled from node
+ // and the return type is NodeJS.Timeout object
+ let timerId: number;
this._loadingPromise = Promise.race([
new Promise(resolve => (this._loadingResolver = resolve)),
new Promise(
(_, reject) =>
- (timerId = setTimeout(() => {
+ (timerId = window.setTimeout(() => {
reject(new Error(this._timeout()));
}, PLUGIN_LOADING_TIMEOUT_MS))
),
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
index 8e5389c..668834e 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
@@ -361,8 +361,9 @@
eventDetails
);
if (type === ERROR.TYPE && category === ERROR.CATEGORY.EXCEPTION) {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- console.error((eventValue && (eventValue as any).error) || eventName);
+ console.error(
+ (typeof eventValue === 'object' && eventValue.error) || eventName
+ );
}
// We report events immediately when metrics plugin is loaded