Skip to content

Commit c55abb4

Browse files
fix: resolve existing typecheck errors
1 parent 1021c1d commit c55abb4

6 files changed

Lines changed: 52 additions & 30 deletions

File tree

src/components/blogCarousel/blogCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ const BlogCard = ({ type, date, title, content, imageUrl, id, authors }) => {
8585
onError={(e) => {
8686
const target = e.currentTarget;
8787
target.style.display = "none";
88-
const fallback = target.nextElementSibling;
88+
const fallback =
89+
target.nextElementSibling as HTMLElement | null;
8990
if (fallback) fallback.style.display = "flex";
9091
}}
9192
/>

src/components/discussions/DiscussionCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ export default function DiscussionCard({
129129
onError={(e) => {
130130
const target = e.currentTarget;
131131
target.style.display = "none";
132-
const fallback = target.nextElementSibling;
132+
const fallback =
133+
target.nextElementSibling as HTMLElement | null;
133134
if (fallback) fallback.style.display = "flex";
134135
}}
135136
/>

src/pages/blogs/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ const BlogCard = ({ blog, index }) => {
297297
onError={(e) => {
298298
const target = e.currentTarget;
299299
target.style.display = "none";
300-
const fallback = target.nextElementSibling;
300+
const fallback =
301+
target.nextElementSibling as HTMLElement | null;
301302
if (fallback) fallback.style.display = "flex";
302303
}}
303304
/>

src/pages/merch/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useEffect } from "react";
22
import type { ReactNode } from "react";
33
import Layout from "@theme/Layout";
4-
import { motion } from "framer-motion";
4+
import { motion, type Variants } from "framer-motion";
55
import ProductGrid from "../../components/merch/ProductGrid";
66
import FilterBar from "../../components/merch/FilterBar";
77
import ShoppingCart from "../../components/merch/ShoppingCart";
@@ -83,15 +83,15 @@ const sampleProducts: Product[] = [
8383
},
8484
];
8585

86-
const containerVariants = {
86+
const containerVariants: Variants = {
8787
hidden: { opacity: 0 },
8888
show: {
8989
opacity: 1,
9090
transition: { staggerChildren: 0.2 }
9191
}
9292
};
9393

94-
const itemVariants = {
94+
const itemVariants: Variants = {
9595
hidden: { opacity: 0, y: 20 },
9696
show: { opacity: 1, y: 0, transition: { duration: 0.5, ease: "easeOut" } }
9797
};

src/theme/Navbar/Content/index.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,24 @@ function NavbarItems({ items }: { items: NavbarItemConfig[] }): ReactNode {
3838
return (
3939
<>
4040
{items.map((item, i) => {
41-
const key = `${item.label || item.to || item.href || "item"}-${i}`;
41+
const itemKey =
42+
("label" in item && item.label) ||
43+
("to" in item && item.to) ||
44+
("href" in item && item.href) ||
45+
"item";
46+
const key = `${itemKey}-${i}`;
4247
return (
4348
<ErrorCauseBoundary
4449
key={key}
45-
onError={(error) =>
46-
new Error(
50+
onError={(error) => {
51+
const boundaryError = new Error(
4752
`A theme navbar item failed to render.
4853
Please double-check the following navbar item (themeConfig.navbar.items) of your Docusaurus config:
4954
${JSON.stringify(item, null, 2)}`,
50-
{ cause: error },
51-
)
52-
}
55+
);
56+
(boundaryError as Error & { cause?: unknown }).cause = error;
57+
return boundaryError;
58+
}}
5359
>
5460
<NavbarItem {...item} />
5561
</ErrorCauseBoundary>

src/types/global.d.ts

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ declare module "@docusaurus/theme-common" {
3434

3535
export function useThemeConfig(): any;
3636
export function usePluralForm(): any;
37-
export function isMultiColumnFooterLinks(): any;
37+
export function isMultiColumnFooterLinks(links: any): any;
3838
export const ThemeClassNames: any;
3939
export const ErrorCauseBoundary: any;
4040
}
@@ -90,7 +90,10 @@ declare module "@site/src/lib/utils" {
9090
}
9191

9292
declare module "@site/src/utils/jsUtils" {
93-
export function sortBy(array: any[], key: string): any[];
93+
export function sortBy<T>(
94+
array: T[],
95+
getter: (item: T) => string | number | boolean,
96+
): T[];
9497
}
9598

9699
declare module "@site/src/services/github" {
@@ -100,6 +103,24 @@ declare module "@site/src/services/github" {
100103
}
101104
}
102105

106+
declare module "@site/src/services/githubService" {
107+
export const githubService: {
108+
setToken(token: string): void;
109+
fetchDiscussions(limit?: number, signal?: AbortSignal): Promise<any[]>;
110+
};
111+
export interface GitHubDiscussion {
112+
[key: string]: any;
113+
}
114+
}
115+
116+
declare module "@site/src/utils/useSafeColorMode" {
117+
export function useSafeColorMode(): {
118+
colorMode: "light" | "dark";
119+
isDark: boolean;
120+
mounted: boolean;
121+
};
122+
}
123+
103124
declare module "@site/src/components/ui/button" {
104125
export const Button: any;
105126
}
@@ -108,25 +129,17 @@ declare module "@site/src/database/sponsors" {
108129
export interface Sponsor {
109130
[key: string]: any;
110131
}
132+
const sponsors: Sponsor[];
133+
export default sponsors;
111134
}
112135

113136
declare module "@site/src/data/users" {
114-
export interface Tag {
115-
[key: string]: any;
116-
}
117-
export interface TagList {
118-
[key: string]: any;
119-
}
120-
export interface Tags {
121-
[key: string]: any;
122-
}
123-
export interface TagType {
124-
[key: string]: any;
125-
}
126-
export interface User {
127-
[key: string]: any;
128-
}
129-
export const sortedUsers: any;
137+
export type Tag = import("../data/users").Tag;
138+
export type TagType = import("../data/users").TagType;
139+
export type User = import("../data/users").User;
140+
export const Tags: { [type in TagType]: Tag };
141+
export const TagList: TagType[];
142+
export const sortedUsers: User[];
130143
}
131144

132145
// Catch-all for any missing modules

0 commit comments

Comments
 (0)