Skip to content

Commit 3ef1cdd

Browse files
committed
More typescript updates.
Also updates the UsefulLinks class to a functional component
1 parent 1d37a43 commit 3ef1cdd

15 files changed

+198
-206
lines changed

@types/index.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"react": "18.2.0",
2727
"react-content-loader": "6.2.0",
2828
"react-copy-to-clipboard": "5.1.0",
29-
"react-diff-view": "2.4.2",
29+
"react-diff-view": "^3.2.0",
3030
"react-dom": "18.2.0",
3131
"react-dom-confetti": "0.2.0",
3232
"react-ga": "3.3.1",
@@ -46,6 +46,7 @@
4646
"@types/react": "18.2.0",
4747
"@types/react-copy-to-clipboard": "^5.0.7",
4848
"@types/react-dom": "^18.2.18",
49+
"@types/semver": "^7.5.6",
4950
"@types/use-persisted-state": "^0.3.4",
5051
"@typescript-eslint/eslint-plugin": "^6.20.0",
5152
"@typescript-eslint/parser": "^6.20.0",

src/components/common/BinaryDownload.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,32 @@ interface BinaryListProps {
4747
packageName: string
4848
}
4949

50-
const BinaryList = ({
50+
const BinaryList: React.FC<BinaryListProps> = ({
5151
binaryFiles,
5252
toVersion,
5353
appName,
5454
packageName,
55-
}: BinaryListProps) =>
56-
binaryFiles.map(({ newPath }, index) => {
57-
return (
58-
<BinaryRow key={index} index={index}>
59-
{removeAppPathPrefix(newPath, appName)}
55+
}) => {
56+
return (
57+
<>
58+
{binaryFiles.map(({ newPath }, index) => {
59+
return (
60+
<BinaryRow key={index} index={index}>
61+
{removeAppPathPrefix(newPath, appName)}
62+
63+
<DownloadFileButton
64+
open={true}
65+
version={toVersion}
66+
path={newPath}
67+
packageName={packageName}
68+
/>
69+
</BinaryRow>
70+
)
71+
})}
72+
</>
73+
)
74+
}
6075

61-
<DownloadFileButton
62-
open={true}
63-
version={toVersion}
64-
path={newPath}
65-
packageName={packageName}
66-
/>
67-
</BinaryRow>
68-
)
69-
})
7076
interface BinaryDownloadProps {
7177
diff: any[]
7278
fromVersion: string

src/components/common/CopyFileButton.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState } from 'react'
22
import styled from '@emotion/styled'
33
import { Button, Popover } from 'antd'
4+
import type { ButtonProps } from 'antd'
45
import { getBinaryFileURL, replaceAppDetails } from '../../utils'
56
import { CopyOutlined } from '@ant-design/icons'
67

@@ -9,8 +10,25 @@ const popoverContentOpts = {
910
copied: 'Copied!',
1011
}
1112

13+
interface CopyFileButtonProps extends ButtonProps {
14+
open: boolean
15+
version: string
16+
path: string
17+
packageName: string
18+
appName: string
19+
appPackage: string
20+
}
21+
1222
const CopyFileButton = styled(
13-
({ open, version, path, packageName, appName, appPackage, ...props }) => {
23+
({
24+
open,
25+
version,
26+
path,
27+
packageName,
28+
appName,
29+
appPackage,
30+
...props
31+
}: CopyFileButtonProps) => {
1432
const [popoverContent, setPopoverContent] = useState(
1533
popoverContentOpts.default
1634
)

src/components/common/Diff/DiffComment.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React, { useState } from 'react'
22
import styled from '@emotion/styled'
3-
import { HTMLMotionProps, motion } from 'framer-motion'
3+
import { HTMLMotionProps, MotionProps, motion } from 'framer-motion'
44
import { removeAppPathPrefix, getVersionsContentInDiff } from '../../../utils'
55
import Markdown from '../Markdown'
66
import type { Theme } from '../../../theme'
7-
interface ContainerProps extends HTMLMotionProps<'div'> {
7+
interface ContainerProps
8+
extends React.PropsWithChildren<HTMLMotionProps<'div'>> {
89
isCommentOpen: boolean
910
lineChangeType: 'add' | 'delete'
1011
theme?: Theme
@@ -28,7 +29,7 @@ const Container = styled(
2829
}}
2930
inherit={false}
3031
>
31-
<div children={children} />
32+
<div>{children}</div>
3233
</motion.div>
3334
)
3435
}
@@ -62,7 +63,7 @@ const ContentContainer = styled.div<ContentContainerProps>`
6263
user-select: none;
6364
`
6465

65-
interface ShowButtonProps extends DivProps {
66+
interface ShowButtonProps extends HTMLMotionProps<'div'> {
6667
isCommentOpen: boolean
6768
theme?: Theme
6869
}

src/components/common/Diff/DiffViewStyleOptions.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import styled from '@emotion/styled'
33
import { Radio } from 'antd'
44
import type { Theme } from '../../../theme'
55

6+
export type DiffViewStyle = 'split' | 'unified'
67
interface DiffViewStyleOptionsProps {
7-
handleViewStyleChange: (style: string) => void
8-
diffViewStyle: string
8+
handleViewStyleChange: (style: DiffViewStyle) => void
9+
diffViewStyle: DiffViewStyle
910
theme?: Theme
1011
}
1112
const DiffViewStyleOptions = styled(

src/components/common/DiffViewer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import DiffSection from './Diff/DiffSection'
99
import DiffLoading from './Diff/DiffLoading'
1010
import UsefulContentSection from './UsefulContentSection'
1111
import BinaryDownload from './BinaryDownload'
12-
import ViewStyleOptions from './Diff/DiffViewStyleOptions'
12+
import ViewStyleOptions, { DiffViewStyle } from './Diff/DiffViewStyleOptions'
1313
import CompletedFilesCounter from './CompletedFilesCounter'
1414
import { useFetchDiff } from '../../hooks/fetch-diff'
1515
import type { Theme } from '../../theme'
@@ -123,11 +123,11 @@ const DiffViewer = ({
123123

124124
const resetCompletedDiffs = () => setCompletedDiffs([])
125125

126-
const [diffViewStyle, setViewStyle] = useState(
127-
localStorage.getItem('viewStyle') || 'split'
126+
const [diffViewStyle, setViewStyle] = useState<DiffViewStyle>(
127+
(localStorage.getItem('viewStyle') || 'split') as DiffViewStyle
128128
)
129129

130-
const handleViewStyleChange = (newViewStyle) => {
130+
const handleViewStyleChange = (newViewStyle: DiffViewStyle) => {
131131
setViewStyle(newViewStyle)
132132
localStorage.setItem('viewStyle', newViewStyle)
133133
}

src/components/common/TroubleshootingGuidesButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const TroubleshootingGuidesButton = () => {
2121
const [showContent, setShowContent] = useState(false)
2222
const hasHandledClick = useRef(false)
2323

24-
const handlePopoverVisibilityChange = (visibility) => {
24+
const handlePopoverVisibilityChange = () => {
2525
if (hasHandledClick.current) {
2626
return
2727
}

src/components/common/UpgradeSupportAlert.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import React from 'react'
22
import styled from '@emotion/styled'
33
import { Tooltip } from 'antd'
4+
import type { Theme } from '../../theme'
45

5-
const UpgradeSupportAlert = styled((props) => (
6+
interface UpgradeSupportAlertProps
7+
extends React.HTMLAttributes<HTMLDivElement> {
8+
theme?: Theme
9+
}
10+
const UpgradeSupportAlert = styled((props: UpgradeSupportAlertProps) => (
611
<div {...props}>
712
<span>
813
Check out{' '}

src/components/common/UsefulContentSection.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ const Title = styled(({ isContentOpen, ...props }: TitleProps) => (
6666
padding: 18px 0px 0px 14px;
6767
`
6868

69-
interface ContentContainerProps extends HTMLMotionProps<'div'> {
69+
interface ContentContainerProps
70+
extends React.PropsWithChildren<HTMLMotionProps<'div'>> {
7071
isContentOpen: boolean
7172
}
7273

@@ -89,7 +90,7 @@ const ContentContainer = styled(
8990
}}
9091
inherit={false}
9192
>
92-
<div children={children} />
93+
<div>{children}</div>
9394
</motion.div>
9495
)
9596
)`
@@ -243,7 +244,11 @@ class UsefulContentSection extends Component<
243244

244245
<ContentContainer isContentOpen={isContentOpen}>
245246
{doesAnyVersionHaveUsefulLinks ? (
246-
<UsefulLinks packageName={packageName} versions={versions} />
247+
<UsefulLinks
248+
packageName={packageName}
249+
versions={versions}
250+
toVersion={toVersion}
251+
/>
247252
) : null}
248253

249254
<AlignDepsAlert />

0 commit comments

Comments
 (0)