Skip to content

Commit 573fe44

Browse files
authored
chore: upgrade next (#1208)
* chore: upgrade next * fix: jsx preserve * fix: type errors * fix: linting * fix: linting * chore: upgrade react and fix type errors
1 parent d598eef commit 573fe44

File tree

17 files changed

+1703
-2801
lines changed

17 files changed

+1703
-2801
lines changed

.eslintrc.json

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
{
2-
"extends": "next/core-web-vitals",
2+
"extends": ["eslint:recommended"],
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 2021,
6+
"sourceType": "module",
7+
"ecmaFeatures": {
8+
"jsx": true
9+
}
10+
},
11+
"env": {
12+
"browser": true,
13+
"es2021": true,
14+
"node": true
15+
},
316
"rules": {
4-
"react/no-unescaped-entities": "off"
5-
}
17+
"react/no-unescaped-entities": "off",
18+
"no-unused-vars": "off",
19+
"no-undef": "off",
20+
"no-extra-boolean-cast": "off",
21+
"no-unreachable": "off"
22+
},
23+
"ignorePatterns": [
24+
".next/**",
25+
"node_modules/**",
26+
"out/**",
27+
"public/**",
28+
"pages/api/og.tsx"
29+
]
630
}

components/Typedoc/Provider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { createContext, useContext } from "react";
22
import { TypedocPage } from "@/lib/typedoc";
33

4-
const TypedocsContext = createContext<{ typedocs: TypedocPage[] }>({
5-
typedocs: [],
6-
});
4+
const TypedocsContext = createContext<{ typedocs: TypedocPage[] } | undefined>(
5+
undefined,
6+
);
77

88
export const TypedocsProvider = ({
99
children,

components/ui/Autocomplete.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ScrollerBottomGradient } from "./Page/ScrollerBottomGradient";
1313
import Link from "next/link";
1414
import { useRouter } from "next/router";
1515
import React, {
16+
RefObject,
1617
useCallback,
1718
useEffect,
1819
useMemo,
@@ -629,7 +630,7 @@ const Autocomplete = () => {
629630
>
630631
{/* Adds a white shadow to the bottom of the autocomplete when items below scroll */}
631632
<ScrollerBottomGradient
632-
scrollerRef={scrollerRef}
633+
scrollerRef={scrollerRef as RefObject<HTMLDivElement>}
633634
gradientProps={{
634635
height: "20",
635636
}}

components/ui/Breadcrumbs.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const Breadcrumbs = ({ pages }: BreadcrumbsProps) => {
3232
size="2"
3333
color="gray"
3434
style={{
35-
// @ts-expect-error shut it
3635
textWrap: "nowrap",
3736
}}
3837
>

components/ui/Callout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const Callout = ({
4444
isCentered?: boolean;
4545
maxWidth?: string;
4646
style?: React.CSSProperties;
47-
}): JSX.Element => {
47+
}): React.JSX.Element => {
4848
// Determine emoji and bgColor:
4949
// 1. If type is provided, use type's config
5050
// 2. If custom emoji/bgColor provided, use those

components/ui/Card.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type ReactElement } from "react";
1+
import { type ReactElement, type ReactNode } from "react";
22
import { Box, Stack } from "@telegraph/layout";
33
import { MenuItem } from "@telegraph/menu";
44
import Link from "next/link";
@@ -7,12 +7,18 @@ import { Text } from "@telegraph/typography";
77
type Props = {
88
emoji?: string;
99
title: string;
10+
children?: ReactNode;
1011
linkUrl: string;
1112
footer?: ReactElement;
1213
isExternal?: boolean;
1314
};
1415

15-
const CardGroup = ({ children, cols = 2 }) => (
16+
type CardGroupProps = {
17+
children: ReactNode;
18+
cols?: number;
19+
};
20+
21+
const CardGroup = ({ children, cols = 2 }: CardGroupProps) => (
1622
<Stack
1723
style={{
1824
display: "grid",
@@ -24,14 +30,14 @@ const CardGroup = ({ children, cols = 2 }) => (
2430
</Stack>
2531
);
2632

27-
const Card: React.FC<Props> = ({
33+
const Card = ({
2834
emoji,
2935
title,
3036
children,
3137
footer,
3238
linkUrl,
3339
isExternal = false,
34-
}) => (
40+
}: Props) => (
3541
<Stack h="full" rounded="2" border="px" borderColor="gray-4">
3642
<MenuItem
3743
h="full"

components/ui/NavItem.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,16 @@ const NavItem = ({
8181
<Text
8282
as="span"
8383
weight="medium"
84-
style={{
85-
fontSize: "13px",
86-
// @ts-expect-error textWrap is fine
87-
textWrap: "nowrap",
88-
// Easy way to vertically align the text
89-
verticalAlign: "text-bottom",
90-
"--color": isActive ? "var(--tgph-gray-12)" : "var(--tgph-gray-11)",
91-
...(textProps.style || {}),
92-
}}
84+
style={
85+
{
86+
fontSize: "13px",
87+
textWrap: "nowrap",
88+
// Easy way to vertically align the text
89+
verticalAlign: "text-bottom",
90+
"--color": isActive ? "var(--tgph-gray-12)" : "var(--tgph-gray-11)",
91+
...(textProps.style || {}),
92+
} as React.CSSProperties
93+
}
9394
{...textPropsWithoutStyle}
9495
>
9596
{children}

components/ui/OverviewContent/Blocks.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import React from "react";
88
import Image from "next/image";
99
import { TgphComponentProps } from "@telegraph/helpers";
1010

11-
type IconComponent = () => JSX.Element;
11+
type IconComponent = () => React.JSX.Element;
1212
type IconType = keyof typeof Icons | LucideIcon | IconComponent;
1313

14-
function getIcon(icon?: IconType): IconComponent | React.ReactNode {
14+
function getIcon(icon?: IconType): IconComponent | LucideIcon {
1515
if (typeof icon === "function") {
16-
return icon as IconComponent;
16+
return icon as IconComponent | LucideIcon;
1717
}
1818

1919
if (typeof icon === "string") {
@@ -22,7 +22,7 @@ function getIcon(icon?: IconType): IconComponent | React.ReactNode {
2222
// can't be properly type checked.
2323
const lowercasedIcon = icon.toLowerCase();
2424
if (Icons[lowercasedIcon as keyof typeof Icons]) {
25-
return Icons[lowercasedIcon as keyof typeof Icons] as () => JSX.Element;
25+
return Icons[lowercasedIcon as keyof typeof Icons] as IconComponent;
2626
}
2727

2828
// We throw an error here so that a build can't complete if there is an icon that
@@ -32,7 +32,7 @@ function getIcon(icon?: IconType): IconComponent | React.ReactNode {
3232
);
3333
}
3434

35-
return icon as React.ReactNode;
35+
return icon as unknown as LucideIcon;
3636
}
3737

3838
export const Tool = ({
@@ -66,7 +66,7 @@ export const Tool = ({
6666
>
6767
{typeof _icon === "function" ? (
6868
<Box w="8" h="8" bg="black" color="white" p="2" borderRadius="2">
69-
{_icon()}
69+
{(_icon as IconComponent)()}
7070
</Box>
7171
) : (
7272
<Icon
@@ -134,7 +134,7 @@ export const ContentCard = ({
134134
>
135135
{typeof _icon === "function" ? (
136136
<Box w="10" h="10" bg="gray-2" p="2" borderRadius="2">
137-
{_icon()}
137+
{(_icon as IconComponent)()}
138138
</Box>
139139
) : (
140140
<Icon

components/ui/Page/OnThisPage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState, useRef } from "react";
1+
import React, { useEffect, useState, useRef, RefObject } from "react";
22
import Link from "next/link";
33
import { Box, Stack } from "@telegraph/layout";
44
import { Text as TextIcon } from "lucide-react";
@@ -156,7 +156,9 @@ const OnThisPage: React.FC<Props> = ({ title, sourcePath }) => {
156156
>
157157
<HeaderList headers={headers} nesting={0} />
158158
</Stack>
159-
<ScrollerBottomGradient scrollerRef={scrollerRef} />
159+
<ScrollerBottomGradient
160+
scrollerRef={scrollerRef as RefObject<HTMLDivElement>}
161+
/>
160162
<Box borderTop="px" borderColor="gray-3" mb="4" />
161163
<Text
162164
as="a"

components/ui/Page/ScrollerBottomGradient.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Box } from "@telegraph/layout";
33
import { TgphComponentProps } from "@telegraph/helpers";
44

55
export function useOnRefReady<T extends HTMLElement>(
6-
ref: React.RefObject<T>,
6+
ref: React.RefObject<T | null>,
77
callback: (node: T) => void,
88
) {
99
const lastNodeRef = useRef<T | null>(null);

0 commit comments

Comments
 (0)