Typescript config parity with Browsertrix repo (#289)

Follow-up from #288 

This matches the strictness rules with the Browsertrix repo,
specifically `noImplicitAny`, and then adds `// @ts-expect-error`s to
suppress existing errors this change raises. This'll help us keep code
quality high moving forward.

Going to just directly merge this once it passes CI; as with #288, this
doesn't change any code, just comments.
This commit is contained in:
Emma Segal-Grossman
2024-03-07 21:12:26 -05:00
committed by GitHub
parent 40d84f3383
commit 5c7b914e69
21 changed files with 121 additions and 19 deletions
+25
View File
@@ -257,8 +257,10 @@ class Item extends LitElement {
Object.entries(this.tabData).forEach(([key, value]) => {
if (!value) return;
if (key === "multiTs" && typeof value === "string") {
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7053 - Element implicitly has an 'any' type because expression of type '"multiTs"' can't be used to index type '{}'.
tabData[key] = value.split(",");
} else {
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7053 - Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
tabData[key] = value;
}
});
@@ -447,6 +449,7 @@ class Item extends LitElement {
this.onHashChange();
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onItemLoaded(event) {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
@@ -465,6 +468,7 @@ class Item extends LitElement {
);
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onItemUpdate(event) {
if (!this.editable) {
return;
@@ -522,6 +526,7 @@ class Item extends LitElement {
}
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onTabClick(event) {
event.preventDefault();
const hash = event.currentTarget.getAttribute("href");
@@ -530,6 +535,7 @@ class Item extends LitElement {
return false;
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onItemTabNav(event) {
if (event.detail.reload) {
this.onRefresh(null, true);
@@ -556,6 +562,7 @@ class Item extends LitElement {
}
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'data' implicitly has an 'any' type.
updateTabData(data, replaceLoc = false /*, merge = false*/) {
this.tabData = { ...this.tabData, ...data };
if (this.tabData.url) {
@@ -961,6 +968,7 @@ class Item extends LitElement {
}
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'isSidebar' implicitly has an 'any' type.
renderTabHeader(isSidebar) {
// if (this.tabData.view === "replay") {
// return "";
@@ -1536,6 +1544,7 @@ class Item extends LitElement {
return "";
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'isSidebar' implicitly has an 'any' type.
renderItemTabs(isSidebar) {
const isStory = this.hasStory && this.tabData.view === "story";
const isPages = this.tabData.view === "pages";
@@ -1603,6 +1612,7 @@ class Item extends LitElement {
`;
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
skipMenu(event) {
// This is a workaround, since this app's routing doesn't permit normal
// following of in-page anchors.
@@ -1610,6 +1620,7 @@ class Item extends LitElement {
this.renderRoot.querySelector<HTMLElement>("#skip-replay-target")?.focus();
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onKeyDown(event) {
if (event.key === "Esc" || event.key === "Escape") {
event.preventDefault();
@@ -1617,6 +1628,7 @@ class Item extends LitElement {
}
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onMenu(event) {
event.stopPropagation();
this.menuActive = !this.menuActive;
@@ -1632,6 +1644,7 @@ class Item extends LitElement {
}
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onFullscreenToggle(event) {
event.preventDefault();
this.menuActive = false;
@@ -1646,18 +1659,21 @@ class Item extends LitElement {
}
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onGoBack(event) {
event.preventDefault();
this.menuActive = false;
window.history.back();
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onGoForward(event) {
event.preventDefault();
this.menuActive = false;
window.history.forward();
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onShowPages(event) {
event.preventDefault();
// show sidebar for tablet or wider, or hide sidebar
@@ -1670,16 +1686,19 @@ class Item extends LitElement {
}
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onFullPageView(event) {
event.preventDefault();
this.updateTabData({ url: "", ts: "" });
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onHideSidebar(event) {
event.preventDefault();
this.showSidebar = false;
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
async onFavIcons(event) {
for (const icon of event.detail.icons) {
// TODO: Fix this the next time the file is edited.
@@ -1698,6 +1717,7 @@ class Item extends LitElement {
this.favIconUrl = "";
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onPurgeCache(event) {
event.preventDefault();
@@ -1731,6 +1751,7 @@ class Item extends LitElement {
window.location.reload();
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onSubmit(event) {
event.preventDefault();
const input = this.renderRoot.querySelector<HTMLInputElement>("input")!;
@@ -1742,6 +1763,7 @@ class Item extends LitElement {
return false;
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type.
onLostFocus(event) {
if (!event.currentTarget.value) {
event.currentTarget.value = this.url;
@@ -1769,6 +1791,7 @@ class Item extends LitElement {
this.updateTabData({ ts: item.value });
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'value' implicitly has an 'any' type.
navigateTo(value) {
let data;
@@ -1792,6 +1815,7 @@ class Item extends LitElement {
this.updateTabData(data);
}
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'value' implicitly has an 'any' type.
_stringToParams(value) {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
@@ -1808,6 +1832,7 @@ class Item extends LitElement {
"urlSearchType",
]) {
if (q.has(param)) {
// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7053 - Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Partial<URLResource>'.
data[param] = q.get(param);
}
}