Skip to content

Commit 0dca748

Browse files
authored
Refactor: stricter type declarations (darkreader#7058)
1 parent cf13e90 commit 0dca748

9 files changed

Lines changed: 14 additions & 8 deletions

File tree

src/inject/dynamic-theme/stylesheet-proxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function injectProxy() {
9696
// current situation of the DOM. Instead of a static list.
9797
const NodeListBehavior: ProxyHandler<NodeListOf<HTMLElement>> = {
9898
get: function (_: NodeListOf<HTMLElement>, property: string) {
99-
return getCurrentElementValue()[property];
99+
return getCurrentElementValue()[Number(property)];
100100
}
101101
};
102102
elements = new Proxy(elements, NodeListBehavior);

src/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"compilerOptions": {
3+
"noImplicitAny": true,
34
"target": "es2019",
45
"baseUrl": ".",
56
"module": "es2015",

src/ui/controls/button/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {m} from 'malevic';
22
import {mergeClass, omitAttrs} from '../utils';
33

4-
export default function Button(props: Malevic.NodeAttrs, ...children) {
4+
export default function Button(props: Malevic.NodeAttrs, ...children: Malevic.Child[]) {
55
const cls = mergeClass('button', props.class);
66
const attrs = omitAttrs(['class'], props);
77

src/ui/controls/checkbox/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {m} from 'malevic';
22
import {mergeClass, omitAttrs} from '../utils';
33

4-
export default function CheckBox(props: Malevic.NodeAttrs, ...children) {
4+
export default function CheckBox(props: Malevic.NodeAttrs, ...children: Malevic.Child[]) {
55
const cls = mergeClass('checkbox', props.class);
66
const attrs = omitAttrs(['class', 'checked', 'onchange'], props);
77
const check = (domNode: HTMLInputElement) => domNode.checked = Boolean(props.checked);

src/ui/controls/multi-switch/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface MultiSwitchProps {
77
onChange: (value: string) => void;
88
}
99

10-
export default function MultiSwitch(props: MultiSwitchProps, ...children) {
10+
export default function MultiSwitch(props: MultiSwitchProps, ...children: Malevic.Child[]) {
1111
return (
1212
<span class={['multi-switch', props.class]}>
1313
<span

src/ui/controls/tab-panel/tab.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import {m} from 'malevic';
22

3-
export default function Tab({isActive}, ...children) {
3+
interface TabProps {
4+
isActive: boolean;
5+
}
6+
7+
export default function Tab({isActive}: TabProps, ...children: Malevic.Child[]) {
48
const tabCls = {
59
'tab-panel__tab': true,
610
'tab-panel__tab--active': isActive

src/utils/log.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
declare const __DEBUG__: boolean;
22
const DEBUG = __DEBUG__;
33

4-
export function logInfo(...args) {
4+
export function logInfo(...args: any[]) {
55
DEBUG && console.info(...args);
66
}
77

8-
export function logWarn(...args) {
8+
export function logWarn(...args: any[]) {
99
DEBUG && console.warn(...args);
1010
}

src/utils/platform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ export const isXMLHttpRequestSupported = typeof XMLHttpRequest === 'function';
5050

5151
export const isFetchSupported = typeof fetch === 'function';
5252

53-
export const isMV3 = globalThis.chrome && globalThis.chrome.runtime && globalThis.chrome.runtime.getManifest && globalThis.chrome.runtime.getManifest().manifest_version === 3;
53+
export const isMV3 = (globalThis as any).chrome && (globalThis as any).chrome.runtime && (globalThis as any).chrome.runtime.getManifest && (globalThis as any).chrome.runtime.getManifest().manifest_version === 3;

tasks/bundle-js.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ async function bundleJS(/** @type {JSEntry} */entry, {debug, watch}) {
127127
tsconfig: 'src/tsconfig.json',
128128
tsconfigOverride: {
129129
compilerOptions: {
130+
noImplicitAny: debug ? false : true,
130131
removeComments: debug ? false : true,
131132
sourceMap: debug ? true : false,
132133
},

0 commit comments

Comments
 (0)