Skip to content

Commit 5c88665

Browse files
committed
Add types
1 parent bd52502 commit 5c88665

12 files changed

Lines changed: 44 additions & 37 deletions

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import Header from "~/components/Header";
88
// import Footer from "~/components/Footer";
99

1010
function App({ url }: Props & { url?: string }): JSX.Element {
11-
const [isMenuOpen, setMenuOpen] = useState(false);
12-
const [isMenuShown] = useState(true);
11+
const [isMenuOpen, setMenuOpen] = useState<boolean>(false);
12+
const [isMenuShown] = useState<boolean>(true);
1313

1414
return (
1515
<StrictMode>

src/AppHistory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function useAppHistory(): object {
1212

1313
const idx: RefObject<number> = useRef<number>(-1);
1414

15-
const [index, setIndex] = useState(-1);
15+
const [index, setIndex] = useState<number>(-1);
1616
const stack: RefObject<object[]> = useRef<object[]>([location]);
1717

1818
useEffect((): void => {

src/Constants.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const NOT_TAGS = [
1+
export const NOT_TAGS: string[] = [
22
"porn",
33
"porno",
44
"nsfw",

src/DaemonRPC.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useState } from "react";
22

33
function useDaemonRPC(): string {
4-
const [daemon, setDaemon] = useState(
4+
const [daemon, setDaemon] = useState<string>(
55
new URL(import.meta.env.VITE_DAEMON_STATIC).toString(),
66
);
77

src/Home.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import Loader from "~/components/Loader";
88
function Home(): JSX.Element {
99
const daemonRPC: string = useDaemonRPC();
1010

11-
const [row1, setRow1] = useState([]);
12-
const [row2, setRow2] = useState([]);
13-
const [row3, setRow3] = useState([]);
11+
const [row1, setRow1] = useState<object[]>([]);
12+
const [row2, setRow2] = useState<object[]>([]);
13+
const [row3, setRow3] = useState<object[]>([]);
1414

1515
useEffect((): void => {
1616
LBRY.rpc(
@@ -34,7 +34,7 @@ function Home(): JSX.Element {
3434
},
3535
null,
3636
import.meta.env.VITE_DAEMON_PROXY === "true",
37-
).then((json) => {
37+
).then((json: object): void => {
3838
setRow1(json.result.items);
3939
});
4040
}, [daemonRPC]);
@@ -59,7 +59,7 @@ function Home(): JSX.Element {
5959
},
6060
null,
6161
import.meta.env.VITE_DAEMON_PROXY === "true",
62-
).then((json) => {
62+
).then((json: object): void => {
6363
setRow2(json.result.items);
6464
});
6565
}, [daemonRPC]);
@@ -82,7 +82,7 @@ function Home(): JSX.Element {
8282
},
8383
null,
8484
import.meta.env.VITE_DAEMON_PROXY === "true",
85-
).then((json) => {
85+
).then((json: object): void => {
8686
setRow3(json.result.items);
8787
});
8888
}, [daemonRPC]);

src/NotFound.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function NotFound() {
1+
import { JSX } from "react";
2+
3+
function NotFound(): JSX.Element {
24
if (import.meta.env.SSR) {
35
throw new Error("404_NOT_FOUND");
46
}

src/SearchPage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function SearchPage(): JSX.Element {
1212
const query: string | null = new URLSearchParams(location.search).get("q");
1313

1414
const [resolveItem, setResolveItem] = useState(null);
15-
const [channelSearchItems, setChannelSearchItems] = useState([]);
15+
const [channelSearchItems, setChannelSearchItems] = useState<object[]>([]);
1616

1717
useEffect((): void => {
1818
LBRY.rpc(
@@ -24,7 +24,7 @@ function SearchPage(): JSX.Element {
2424
},
2525
null,
2626
import.meta.env.VITE_DAEMON_PROXY === "true",
27-
).then((json) => {
27+
).then((json: object): void => {
2828
if (
2929
json.result["lbry://" + query] &&
3030
!json.result["lbry://" + query].error
@@ -55,7 +55,7 @@ function SearchPage(): JSX.Element {
5555
},
5656
null,
5757
import.meta.env.VITE_DAEMON_PROXY === "true",
58-
).then((json) => {
58+
).then((json: object): void => {
5959
setChannelSearchItems(json.result.items);
6060
});
6161
}, [daemonRPC, query]);

src/WalletPage.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function WalletPage() {
77
const daemonRPC: string = useDaemonRPC();
88

99
const [wallet, setWallet] = useState(null);
10-
const [transactions, setTransactions] = useState([]);
10+
const [transactions, setTransactions] = useState<object[]>([]);
1111

1212
useEffect((): void => {
1313
LBRY.rpc(
@@ -16,9 +16,8 @@ function WalletPage() {
1616
null,
1717
null,
1818
import.meta.env.VITE_DAEMON_PROXY === "true",
19-
).then((json) => {
19+
).then((json: object): void => {
2020
if (json.error) {
21-
//document.getElementById("wallet").innerHTML = json.error.message;
2221
return;
2322
}
2423
setWallet(json.result);
@@ -32,9 +31,8 @@ function WalletPage() {
3231
null,
3332
null,
3433
import.meta.env.VITE_DAEMON_PROXY === "true",
35-
).then((json) => {
34+
).then((json: object): void => {
3635
if (json.error) {
37-
//document.getElementById("transactions").innerHTML = json.error.message;
3836
return;
3937
}
4038
setTransactions(json.result?.items || []);

src/components/ChannelClaim.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import Error from "~/components/Error";
1010
function ChannelClaim({ data }: Props & { data: Channel }): JSX.Element {
1111
const daemonRPC: string = useDaemonRPC();
1212

13-
const [tab, setTab] = useState("content");
14-
const [content, setContent] = useState([]);
15-
const [playlists, setPlaylists] = useState([]);
13+
const [tab, setTab] = useState<string>("content");
14+
const [content, setContent] = useState<object[]>([]);
15+
const [playlists, setPlaylists] = useState<object[]>([]);
1616

1717
useEffect((): void => {
1818
LBRY.rpc(
@@ -33,7 +33,7 @@ function ChannelClaim({ data }: Props & { data: Channel }): JSX.Element {
3333
},
3434
null,
3535
import.meta.env.VITE_DAEMON_PROXY === "true",
36-
).then(async (json: object) => {
36+
).then((json: object): void => {
3737
setContent(json.result.items);
3838
});
3939
}, [data.claim_id, daemonRPC]);
@@ -57,7 +57,7 @@ function ChannelClaim({ data }: Props & { data: Channel }): JSX.Element {
5757
},
5858
null,
5959
import.meta.env.VITE_DAEMON_PROXY === "true",
60-
).then(async (json: object) => {
60+
).then((json: object): void => {
6161
setPlaylists(json.result.items);
6262
});
6363
}, [data.claim_id, daemonRPC]);
@@ -67,7 +67,7 @@ function ChannelClaim({ data }: Props & { data: Channel }): JSX.Element {
6767
<div id="channel-header">
6868
<div
6969
style={{
70-
backgroundColor:'black',
70+
backgroundColor: "black",
7171
backgroundImage: `url(${data.value.cover?.url})`,
7272
backgroundSize: "cover",
7373
borderTopLeftRadius: "6px",
@@ -78,12 +78,16 @@ function ChannelClaim({ data }: Props & { data: Channel }): JSX.Element {
7878
<div
7979
style={{
8080
backgroundImage:
81-
"linear-gradient(to right, black,transparent 50%)",height:'100%',
81+
"linear-gradient(to right, black,transparent 50%)",
82+
height: "100%",
8283
}}
8384
>
8485
<img
8586
alt="Channel Logo"
86-
src={data.value.thumbnail?.url || 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='}
87+
src={
88+
data.value.thumbnail?.url ||
89+
"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
90+
}
8791
style={{
8892
borderRadius: "100%",
8993
height: "160px",
@@ -170,13 +174,13 @@ function ChannelClaim({ data }: Props & { data: Channel }): JSX.Element {
170174
<div style={{ paddingTop: "32px" }}>
171175
{tab === "content" ? (
172176
<div style={{ textAlign: "center" }}>
173-
{content.map((item, i: number) => (
177+
{content.map((item: object, i: number) => (
174178
<ClaimPreviewTile claim={item} key={i} />
175179
))}
176180
</div>
177181
) : null}
178182
{tab === "playlists"
179-
? playlists.map((item, i: number) => (
183+
? playlists.map((item: object, i: number) => (
180184
<ClaimPreviewTile claim={item} key={i} />
181185
))
182186
: null}

src/components/CollectionClaim.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ import ClaimPreviewTile from "~/components/ClaimPreviewTile";
77
function CollectionClaim({ data }: Props & { data: Collection }): JSX.Element {
88
const daemonRPC: string = useDaemonRPC();
99

10-
const [items, setItems] = useState([]);
10+
const [items, setItems] = useState<object[]>([]);
1111

1212
useEffect((): void => {
1313
LBRY.rpc(
1414
daemonRPC,
1515
"resolve",
1616
{
1717
urls: data.value.claims.map(
18-
(claim: string): string => `lbry://${data.signing_channel.name}:${claim}`,
18+
(claim: string): string =>
19+
`lbry://${data.signing_channel.name}:${claim}`,
1920
),
2021
include_purchase_receipt: true,
2122
},
@@ -38,9 +39,11 @@ function CollectionClaim({ data }: Props & { data: Collection }): JSX.Element {
3839
</Link>
3940
</span>
4041
<div style={{ textAlign: "center" }}>
41-
{items.map((item: object[unknown], i: number): JSX.Element => (
42-
<ClaimPreviewTile claim={item} key={i} />
43-
))}
42+
{items.map(
43+
(item: object[unknown], i: number): JSX.Element => (
44+
<ClaimPreviewTile claim={item} key={i} />
45+
),
46+
)}
4447
</div>
4548
</div>
4649
);

0 commit comments

Comments
 (0)