Skip to content

Commit 513ebf9

Browse files
committed
fix(types): Add minimal types
1 parent 7f37b04 commit 513ebf9

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/pages/index.astro

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
---
22
let data;
3+
interface Repo {
4+
name: string;
5+
html_url: string;
6+
stargazers_count: number;
7+
updated_at: string;
8+
private: boolean;
9+
fork: boolean;
10+
archived: boolean;
11+
}
312
413
const backupData = [
514
{
@@ -36,7 +45,7 @@ async function load() {
3645
},
3746
});
3847
if (res.status === 200) {
39-
const json = await res.json();
48+
const json = (await res.json()) as Repo[];
4049
const repos = json.map((repo) => {
4150
return repo.private === false &&
4251
repo.fork === false &&
@@ -50,9 +59,9 @@ async function load() {
5059
: {};
5160
});
5261
53-
data = repos
54-
.filter((repo) => Object.keys(repo).length !== 0)
55-
.sort((a, b) => b.stargazers_count - a.stargazers_count);
62+
data = (
63+
repos.filter((repo) => Object.keys(repo).length !== 0) as Repo[]
64+
).sort((a, b) => b.stargazers_count - a.stargazers_count);
5665
} else {
5766
data = backupData;
5867
}

0 commit comments

Comments
 (0)