Skip to content

Commit

Permalink
More typescript fixes. typecheck passes.
Browse files Browse the repository at this point in the history
  • Loading branch information
markrickert committed Feb 5, 2024
1 parent 68db304 commit b0470d2
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/components/common/CopyFileButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const CopyFileButton = styled(
<Popover content={popoverContent} trigger="hover">
<Button
{...props}
type="ghost"
ghost
icon={<CopyOutlined />}
onBlur={() => {
setPopoverContent(popoverContentOpts.default)
Expand Down
9 changes: 5 additions & 4 deletions src/components/common/Diff/Diff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import DiffHeader from './DiffHeader'
import { getComments } from './DiffComment'
import { replaceAppDetails } from '../../../utils'
import type { Theme } from '../../../theme'
import type { ChangeEventArgs } from 'react-diff-view'
import type { DefaultRenderToken } from 'react-diff-view/types/context'

const copyPathPopoverContentOpts = {
Expand Down Expand Up @@ -194,7 +195,7 @@ interface DiffProps {
isDiffCompleted: boolean
onCompleteDiff: (diffKey: string) => void
selectedChanges: string[]
onToggleChangeSelection: (change: string) => void
onToggleChangeSelection: (args: ChangeEventArgs) => void
areAllCollapsed?: boolean
setAllCollapsed: (collapse: boolean | undefined) => void
diffViewStyle: ViewType
Expand Down Expand Up @@ -291,13 +292,13 @@ const Diff = ({
diffKey={diffKey}
hasDiff={hunks.length > 0}
isDiffCollapsed={isDiffCollapsed}
setIsDiffCollapsed={(collapse, altKey) => {
setIsDiffCollapsed={(collapsed: boolean, altKey?: boolean) => {
if (altKey) {
return setAllCollapsed(collapse)
return setAllCollapsed(collapsed)
}

setAllCollapsed(undefined)
setIsDiffCollapsed(collapse)
setIsDiffCollapsed(collapsed)
}}
isDiffCompleted={isDiffCompleted}
onCopyPathToClipboard={handleCopyPathToClipboard}
Expand Down
3 changes: 2 additions & 1 deletion src/components/common/Diff/DiffCommentReminder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { motion, HTMLMotionProps } from 'framer-motion'
import { InfoCircleOutlined } from '@ant-design/icons'
import { getTransitionDuration } from '../../../utils'
import type { Theme } from '../../../theme'
import type { ReleaseCommentT } from '../../../releases/types'

interface DiffCommentReminderProps extends HTMLMotionProps<'div'> {
comments: Record<string, string>
comments: ReleaseCommentT[]
isDiffCollapsed: boolean
uncollapseDiff: () => void
theme?: Theme
Expand Down
26 changes: 8 additions & 18 deletions src/components/common/Diff/DiffHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import DownloadFileButton from '../DownloadFileButton'
import ViewFileButton from '../ViewFileButton'
import CopyFileButton from '../CopyFileButton'
import type { Theme } from '../../../theme'
import type { LineChangeT } from '../../../releases/types'
import type { ReleaseCommentT } from '../../../releases/types'
import type { DiffType } from 'react-diff-view'

export const testIDs = {
Expand Down Expand Up @@ -56,7 +56,7 @@ const FileName = ({
}: {
oldPath: string
newPath: string
type: LineChangeT
type: DiffType
}) => {
if (type === 'delete') {
return <span>{oldPath}</span>
Expand Down Expand Up @@ -133,19 +133,9 @@ interface CompleteDiffButtonProps extends ButtonProps {
const CompleteDiffButton = styled(
({ open, onClick, ...props }: CompleteDiffButtonProps) =>
open ? (
<Button
{...props}
type="ghost"
icon={<RollbackOutlined />}
onClick={onClick}
/>
<Button {...props} ghost icon={<RollbackOutlined />} onClick={onClick} />
) : (
<Button
{...props}
type="ghost"
icon={<CheckOutlined />}
onClick={onClick}
/>
<Button {...props} ghost icon={<CheckOutlined />} onClick={onClick} />
)
)`
${defaultIconButtonStyle}
Expand Down Expand Up @@ -187,7 +177,7 @@ const CopyPathToClipboardButton = styled(
>
<Button
{...props}
type="ghost"
ghost
icon={<CopyOutlined />}
onMouseOver={resetCopyPathPopoverContent}
/>
Expand Down Expand Up @@ -243,7 +233,7 @@ const CopyAnchorLinksToClipboardButton = styled(
>
<Button
{...props}
type="ghost"
ghost
icon={<LinkOutlined />}
onMouseOver={resetContent}
/>
Expand Down Expand Up @@ -295,15 +285,15 @@ interface DiffHeaderProps extends WrapperProps {
diffKey: string
hasDiff: boolean
isDiffCollapsed: boolean
setIsDiffCollapsed: (isDiffCollapsed: boolean, altKey: boolean) => void
setIsDiffCollapsed: (isDiffCollapsed: boolean, altKey?: boolean) => void
isDiffCompleted: boolean
onCompleteDiff: (diffKey: string) => void
onCopyPathToClipboard: () => void
copyPathPopoverContent: string
resetCopyPathPopoverContent: () => void
appName: string
appPackage: string
diffComments: string[]
diffComments: ReleaseCommentT[]
packageName: string
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/common/Diff/DiffSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from '@emotion/styled'
import semver from 'semver'
import Diff from './Diff'
import type { File } from 'gitdiff-parser'
import type { ViewType } from 'react-diff-view'
import type { ChangeEventArgs, ViewType } from 'react-diff-view'

export const testIDs = {
diffSection: 'diffSection',
Expand All @@ -25,7 +25,7 @@ interface DiffSectionProps {
toVersion: string
handleCompleteDiff: (diffKey: string) => void
selectedChanges: string[]
onToggleChangeSelection: (diffKey: string) => void
onToggleChangeSelection: (args: ChangeEventArgs) => void
diffViewStyle: ViewType
appName: string
appPackage: string
Expand Down
10 changes: 8 additions & 2 deletions src/components/common/DiffViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import React, { useState, useEffect, useRef, useReducer } from 'react'
import styled from '@emotion/styled'
import { Alert } from 'antd'
import { motion, AnimatePresence, LayoutGroup } from 'framer-motion'
import { type ViewType, withChangeSelect } from 'react-diff-view'
import {
type ViewType,
withChangeSelect,
ChangeEventArgs,
} from 'react-diff-view'
import 'react-diff-view/style/index.css'
import { getTransitionDuration, getChangelogURL } from '../../utils'
import DiffSection from './Diff/DiffSection'
Expand Down Expand Up @@ -65,7 +69,7 @@ interface DiffViewerProps {
toVersion: string
shouldShowDiff: boolean
selectedChanges: string[]
onToggleChangeSelection: (change: string) => void
onToggleChangeSelection: (args: ChangeEventArgs) => void
appName: string
appPackage: string
}
Expand Down Expand Up @@ -248,6 +252,7 @@ const DiffViewer = ({
packageName={packageName}
isDoneSection={true}
title="Done"
diffViewStyle={diffViewStyle}
appName={appName}
appPackage={appPackage}
doneTitleRef={doneTitleRef}
Expand All @@ -266,4 +271,5 @@ const DiffViewer = ({
)
}

// @ts-ignore-next-line
export default withChangeSelect({ multiple: true })(DiffViewer)
2 changes: 1 addition & 1 deletion src/components/common/DownloadFileButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const DownloadFileButton = ({
return open ? (
<Button
{...props}
type="ghost"
ghost
shape="circle"
icon={<DownloadOutlined />}
target="_blank"
Expand Down
1 change: 1 addition & 0 deletions src/components/common/TroubleshootingGuides.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const TroubleshootingGuides = ({

return (
<Container
// @ts-ignore-next-line
willHaveAnimation={willHaveAnimation.current}
animate={containerAnimation}
>
Expand Down
11 changes: 7 additions & 4 deletions src/components/common/VersionSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,26 @@ const ToVersionSelector = styled(
}
`

const getVersionsInURL = () => {
const getVersionsInURL = (): {
fromVersion: string
toVersion: string
} => {
// Parses `/?from=VERSION&to=VERSION` from URL
const { from: fromVersion, to: toVersion } = queryString.parse(
window.location.search
)

return {
fromVersion,
toVersion,
fromVersion: fromVersion as string,
toVersion: toVersion as string,
}
}

// Users making changes to version should not retain anchor links
// to files that may or may not change.
const stripAnchorInUrl = () => {
if (window.location.hash) {
const url = new URL(window.location)
const url = new URL(window.location.toString())
url.hash = ''
window.history.pushState({}, '', url)
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { DarkModeButton } from '../common/DarkModeButton'
import { updateURL } from '../../utils/update-url'
import { deviceSizes } from '../../utils/device-sizes'
import { lightTheme, darkTheme, type Theme } from '../../theme'
import { CheckboxValueType } from 'antd/es/checkbox/Group'

const Page = styled.div<{ theme?: Theme }>`
background-color: ${({ theme }) => theme.background};
Expand Down Expand Up @@ -135,7 +134,7 @@ const Home = () => {
const [fromVersion, setFromVersion] = useState<string>('')
const [toVersion, setToVersion] = useState<string>('')
const [shouldShowDiff, setShouldShowDiff] = useState<boolean>(false)
const [settings, setSettings] = useState({
const [settings, setSettings] = useState<Record<string, boolean>>({
[`${SHOW_LATEST_RCS}`]: false,
})

Expand Down Expand Up @@ -197,7 +196,7 @@ const Home = () => {
setShouldShowDiff(false)
}

const handleSettingsChange = (settingsValues: CheckboxValueType[]) => {
const handleSettingsChange = (settingsValues: string[]) => {
const normalizedIncomingSettings = settingsValues.reduce((acc, val) => {
acc[val] = true
return acc
Expand Down Expand Up @@ -262,7 +261,7 @@ const Home = () => {
language={language}
/>
<DarkModeButton
isDarkMode={isDarkMode}
isDarkMode={isDarkMode as boolean}
onClick={toggleDarkMode}
/>
</SettingsContainer>
Expand Down Expand Up @@ -312,6 +311,7 @@ const Home = () => {
rn-diff-purge output.
*/}
<DiffViewer
//@ts-ignore-next-line
shouldShowDiff={shouldShowDiff}
fromVersion={fromVersion}
toVersion={toVersion}
Expand Down

0 comments on commit b0470d2

Please sign in to comment.