Skip to content

Commit 79b6af4

Browse files
fix: resolve TypeScript type errors (#1151)
1 parent 0edd18a commit 79b6af4

File tree

14 files changed

+50
-39
lines changed

14 files changed

+50
-39
lines changed

rspack.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class RunCommandsPlugin {
137137

138138
isFirstRun = false;
139139

140-
if (this.env.updateUserScripts) {
140+
if (this.env["updateUserScripts"]) {
141141
exec("npx tsx ./script/addUserScriptsComment.ts", (err, stdout) => {
142142
if (err) {
143143
// eslint-disable-next-line no-console
@@ -224,7 +224,7 @@ const unacceptableLicenseTest = (licenseIdentifier: string): boolean => {
224224
return !acceptableLicenses.includes(licenseIdentifier);
225225
};
226226

227-
const isProduction = process.env.NODE_ENV === "production";
227+
const isProduction = process.env["NODE_ENV"] === "production";
228228
/* eslint-disable sort-keys */
229229
// eslint-disable-next-line max-lines-per-function
230230
const config = defineConfig((env) => ({
@@ -233,7 +233,7 @@ const config = defineConfig((env) => ({
233233
entry: {
234234
...chromeScripts,
235235
...firefoxScripts,
236-
...(env.updateUserScripts ? userScriptEntries : {})
236+
...(env["updateUserScripts"] ? userScriptEntries : {})
237237
},
238238
output: {
239239
filename: "[name]",

script/addUserScriptsComment.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ for (const userScript of userScriptFiles) {
2222
);
2323
if (
2424
!isPlainObject(localizedMessages) ||
25-
!isPlainObject(localizedMessages.manifest_description) ||
26-
typeof localizedMessages.manifest_description.message !== "string"
25+
!isPlainObject(localizedMessages["manifest_description"]) ||
26+
typeof localizedMessages["manifest_description"]["message"] !== "string"
2727
) {
2828
throw new Error(`Invalid localized messages for ${languageCode}`);
2929
}
@@ -33,7 +33,7 @@ for (const userScript of userScriptFiles) {
3333
// @name Shadowban Scanner (${languageName})
3434
// @namespace https://github.com/Robot-Inventor/shadowban-scanner/
3535
// @version ${packagejson.version}
36-
// @description ${localizedMessages.manifest_description.message}
36+
// @description ${localizedMessages["manifest_description"]["message"]}
3737
// @author Robot-Inventor (ろぼいん / @keita_roboin)
3838
// @match https://*.twitter.com/*
3939
// @match https://*.x.com/*

script/addonsLinter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const main = async (): Promise<void> => {
1010
config: {
1111
// eslint-disable-next-line id-length
1212
_: ["./dist/firefox/"],
13-
logLevel: process.env.VERBOSE ? "debug" : "fatal",
13+
logLevel: process.env["VERBOSE"] ? "debug" : "fatal",
1414
shouldScanFile: () => true
1515
}
1616
};

script/updatePrivacyPolicy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ for (const file of files) {
1818
const parsedMessages: unknown = JSON.parse(fs.readFileSync(messagePath, "utf8"));
1919
if (
2020
!isPlainObject(parsedMessages) ||
21-
!isPlainObject(parsedMessages.privacyPolicyText) ||
22-
typeof parsedMessages.privacyPolicyText.message !== "string"
21+
!isPlainObject(parsedMessages["privacyPolicyText"]) ||
22+
typeof parsedMessages["privacyPolicyText"]["message"] !== "string"
2323
) {
2424
throw new Error(`Privacy policy text not found in ${messagePath}`);
2525
}
26-
const privacyPolicyText = parsedMessages.privacyPolicyText.message;
26+
const privacyPolicyText = parsedMessages["privacyPolicyText"]["message"];
2727

2828
const newPrivacyPolicySection = `
2929
${START_MARKER}

src/ts/components/sbsMessage.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ class SbsMessage extends LitElement {
4040
public isNoteShown = false;
4141

4242
@property({ attribute: false, reflect: true })
43-
public onRenderedCallback?: () => void;
43+
public onRenderedCallback?: undefined | (() => void);
4444

4545
@property({ reflect: true, type: String })
4646
public textColor = "white";
4747

48-
public static styles = css`
48+
public static override styles = css`
4949
* {
5050
font-family: sans-serif;
5151
}
@@ -224,7 +224,7 @@ class SbsMessage extends LitElement {
224224
event.stopPropagation();
225225
}
226226

227-
protected render(): ReturnType<typeof html> {
227+
protected override render(): ReturnType<typeof html> {
228228
const outerClasses = classMap({
229229
"focal-mode": this.isFocalMode,
230230
"shadowban-scanner-message": true,

src/ts/components/settingsDescription.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { customElement } from "lit/decorators.js";
33

44
@customElement("settings-description")
55
class SettingsDescription extends LitElement {
6-
public static styles = css`
6+
public static override styles = css`
77
:host {
88
display: block;
99
}
@@ -21,7 +21,7 @@ class SettingsDescription extends LitElement {
2121
`;
2222

2323
// eslint-disable-next-line class-methods-use-this
24-
protected render(): ReturnType<typeof html> {
24+
protected override render(): ReturnType<typeof html> {
2525
return html`
2626
<div class="container">
2727
<div class="settings-description">

src/ts/components/settingsItem.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class SettingsItem extends LitElement {
99
@query("md-checkbox")
1010
private checkbox!: MdCheckbox;
1111

12-
public static styles = css`
12+
public static override styles = css`
1313
.settings-item {
1414
display: flex;
1515
flex-direction: row;
@@ -40,7 +40,7 @@ class SettingsItem extends LitElement {
4040
@property({ attribute: true, reflect: true, type: Boolean })
4141
public checked = false;
4242

43-
protected render(): ReturnType<typeof html> {
43+
protected override render(): ReturnType<typeof html> {
4444
return html`
4545
<div class="settings-item">
4646
<label for="${this.settingsName}">

src/ts/components/settingsSeparator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { customElement } from "lit/decorators.js";
33

44
@customElement("settings-separator")
55
class SettingsSeparator extends LitElement {
6-
public static styles = css`
6+
public static override styles = css`
77
.settings-separator {
88
--left-line-width: 0.75rem;
99
@@ -35,7 +35,7 @@ class SettingsSeparator extends LitElement {
3535
`;
3636

3737
// eslint-disable-next-line class-methods-use-this
38-
protected render(): ReturnType<typeof html> {
38+
protected override render(): ReturnType<typeof html> {
3939
return html`
4040
<div class="settings-separator">
4141
<hr />

src/ts/contentScript.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@ import { EVENT_GENERATOR_ID, EVENT_GENERATOR_SETTINGS_ATTRIBUTE } from "./common
22
import { i18n, runtime, storage } from "webextension-polyfill";
33
import { DEFAULT_SETTINGS } from "./common/settings";
44
import { Translator } from "./common/translator";
5+
import { isSettings } from "../types/common/settings.guard";
56

67
// eslint-disable-next-line max-statements
78
const main = async (): Promise<void> => {
89
const settings = await storage.local.get(DEFAULT_SETTINGS);
910

10-
if (["pro.twitter.com", "pro.x.com"].includes(location.hostname) && !settings.enableOnXPro) return;
11+
if (
12+
["pro.twitter.com", "pro.x.com"].includes(location.hostname) &&
13+
isSettings(settings) &&
14+
!settings.enableOnXPro
15+
) {
16+
return;
17+
}
1118

1219
const translator = new Translator(
1320
(key, substitutions) => i18n.getMessage(key, substitutions),

src/ts/core/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Core {
6262
if (!(analyzer.tweet.hasAnyProblem || this.settings.showMessagesInUnproblematicTweets)) return;
6363

6464
if (!tweet.metadata.isFocalMode && this.settings.enableCompactMode) {
65-
tweet.element.dataset.sbCompactMode = analyzer.tweet.hasAnyProblem ? "red" : "green";
65+
tweet.element.dataset["sbCompactMode"] = analyzer.tweet.hasAnyProblem ? "red" : "green";
6666
return;
6767
}
6868

0 commit comments

Comments
 (0)