Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade project to TypeScript #681

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
4d35f14
refactor: fix TypeScript errors in ThemeLoader file
ManpreetSL Dec 9, 2022
1cb9e4c
refactor: fix typo in pronunciationInformation property of the Line type
ManpreetSL Dec 9, 2022
4a88523
refactor: replace any type with Line type in content context
ManpreetSL Dec 9, 2022
c3a3391
refactor: remove explicit string type annotation
ManpreetSL Dec 9, 2022
4af1025
refactor: convert StatusToast file from .js to .tsx file
ManpreetSL Dec 9, 2022
b8199fc
refactor: change Line to a TS file and update its props to TS style
ManpreetSL Dec 17, 2022
545dd63
build(frontend): add shared contract package
ManpreetSL Jan 5, 2023
3d3f9bf
refactor: add types to findLineIndex and customiseLine functions
ManpreetSL Jan 5, 2023
4042ea4
refactor: add types to classifyWord, classifyWords and partitionLine …
ManpreetSL Jan 6, 2023
c9c064c
refactor: clarify sortBy() parameters in Line
ManpreetSL Jan 14, 2023
a15760a
refactor: change Result props from React propTypes to TypeScript style
ManpreetSL Jan 15, 2023
35cf18a
refactor: rename Display and Line to TS files
ManpreetSL Jan 15, 2023
136f230
refactor: update Presenter Line prop types to TypeScript
ManpreetSL Jan 15, 2023
cf12eab
style: update Presenter Line file with Prettier
ManpreetSL Jan 15, 2023
8dcca4a
build: include tsx files in tsconfig
ManpreetSL Jan 15, 2023
dbf0a04
refactor: add some more types to line.ts
ManpreetSL Jan 16, 2023
457b562
refactor: change lineId to only a string and add a default value of ''
ManpreetSL Jan 16, 2023
84b9e40
refactor: move sortBy() to /lib and import it to replace local copies
ManpreetSL Jan 16, 2023
fa3fef9
refactor: update Line types
ManpreetSL Jan 16, 2023
d5d44df
style: update spacing with Prettier in data.ts
ManpreetSL Jan 16, 2023
5865dd3
refactor: split ClientSettings up and export subtypes to use in Display
ManpreetSL Jan 16, 2023
182f932
refactor: replace LineProps types with those already defined in data.ts
ManpreetSL Jan 16, 2023
bf20194
refactor: change Presenter index to a TS file and add some types
ManpreetSL Jan 16, 2023
e694627
refactor: update template strings in Line to handle undefined values
ManpreetSL Jan 16, 2023
165c770
refactor: rename Overlay/index.js to a .tsx file
ManpreetSL Jan 17, 2023
afd1310
refactor: rename Controller/index.js to a .tsx file so its JSX works
ManpreetSL Jan 17, 2023
541de60
refactor: replace Controller/index React propTypes with TypeScript type
ManpreetSL Jan 17, 2023
b322dad
refactor: add a type definition for withNavigationHotkeys props
ManpreetSL Jan 17, 2023
b4dd4d0
refactor: remove undefined type from focused SearchProps property
ManpreetSL Jan 17, 2023
8b83e60
refactor: update Line type to use contract package in contexts file
ManpreetSL Jan 17, 2023
df58b04
refactor: add type to contract for describing information about the app
ManpreetSL Jan 17, 2023
38695d5
refactor: update withContext type in contexts file
ManpreetSL Jan 17, 2023
7dbd94e
refactor: update GetTranslationsParams to fix type spreading type error
ManpreetSL Jan 17, 2023
ef22592
style: adjust ErrorFallback spacing to fix ESLint errors
ManpreetSL Jan 17, 2023
35b8f9f
style: update spacing in Loader and ThemeLoader to fix ESLint errors
ManpreetSL Jan 17, 2023
b4ced8f
refactor: fix invalid date template string in ThemeLoader
ManpreetSL Jan 17, 2023
82a14d9
refactor: filter out booleans from args that should only be numbers
ManpreetSL Jan 18, 2023
7360edb
refactor: add type to getTransliterators return value
ManpreetSL Jan 18, 2023
c5c6660
refactor: cast typeId to a number
ManpreetSL Jan 18, 2023
211330a
fix: remove invalid simpleGraphics argument from Line
ManpreetSL Jan 18, 2023
1265d48
refactor: cast line.gurmukhi as its type wasn't recognised automatically
ManpreetSL Jan 18, 2023
a43cb61
refactor: replace manual array filtering with a util function
ManpreetSL Jan 18, 2023
65a0322
refactor: fix remaining type issues in Presenter/Display
ManpreetSL Jan 18, 2023
0e83b1e
refactor: fix type issue with using any type key in ScreenReader index
ManpreetSL Jan 18, 2023
0a9b545
refactor: add type to focusedIndex param in componentDidUpdate
ManpreetSL Jan 19, 2023
c63f53d
refactor: add class member, props and state types in NavigationHotkeys
ManpreetSL Jan 19, 2023
a91314b
fix: remove duplication of NavigationHotkeys.defaultProps
ManpreetSL Jan 19, 2023
e6c8089
refactor: add type to preventDefault function
ManpreetSL Jan 19, 2023
6fe486e
refactor: add type to focusedIndex param in jumpTo function
ManpreetSL Jan 19, 2023
170cd41
refactor: changed Navigator to a TS file
ManpreetSL Feb 12, 2023
30e83c4
refactor: add types for Navigator and NavigatorLine components
ManpreetSL Feb 13, 2023
9cba274
style: add trailing comma to Keymap type
ManpreetSL Feb 13, 2023
b95beaf
refactor: remove unused prop types import
ManpreetSL Feb 13, 2023
66146f4
style: format spaces in History component
ManpreetSL Feb 13, 2023
726cc3c
refactor: fix ESLint imports error in CopyHotkeys
ManpreetSL Feb 13, 2023
db1f746
refactor: change about props to TS
ManpreetSL Feb 14, 2023
5dc675d
refactor: change CopyButton to TS
ManpreetSL Feb 14, 2023
2fb4055
refactor: change ClosedCaptionSettings to TS
ManpreetSL Feb 14, 2023
c8b7748
refactor: update all prop types in DynamicOptions to TS format
ManpreetSL Feb 14, 2023
3775a4b
refactor: update Settings to TS
ManpreetSL Feb 15, 2023
fbae4f1
refactor: change OverlaySettings to TS
ManpreetSL Feb 15, 2023
c787ab1
refactor: update SettingComponents to TS
ManpreetSL Feb 15, 2023
3dac9b9
refactor: update TutorialButton to TS
ManpreetSL Feb 15, 2023
8668add
style: format frontend index code
ManpreetSL Feb 25, 2023
4a8dda0
fix: fix no-floating-promises ESLint error in frontend index
ManpreetSL Feb 25, 2023
383d677
fix: format onLine() call to fix ESLint max-len error
ManpreetSL Feb 25, 2023
cd2c76d
fix: fix ESLint max-len error with withContexts in App
ManpreetSL Feb 25, 2023
5263659
fix: fix ESLint eol-last error in api types file
ManpreetSL Feb 25, 2023
a48f2fd
refactor: update NavigatorHotKeys props to TS
ManpreetSL Feb 25, 2023
3c89ef3
refactor: rename Result to be a .tsx file
ManpreetSL Feb 26, 2023
b7a084d
refactor: update context types
ManpreetSL Feb 26, 2023
cb58e76
refactor: update Sources to TypeScript
ManpreetSL Feb 26, 2023
e22105c
refactor: update TopBar and BottomBar prop types to TS
ManpreetSL Feb 26, 2023
aa98683
refactor: update icon type in ToolbarButton component
ManpreetSL Feb 26, 2023
cd6ba8f
refactor: add type to SettingComponents export
ManpreetSL Feb 26, 2023
cad6cc4
refactor: add void operator to fix no-floating-promises error in App
ManpreetSL Mar 2, 2023
1d246cd
refactor: update types in App
ManpreetSL Mar 2, 2023
5e13d2b
refactor: add KeyMap type
ManpreetSL Mar 2, 2023
3752ce1
refactor: update types in CopyButton
ManpreetSL Mar 2, 2023
a1da120
refactor: update fontSizes type and usages in Line
ManpreetSL Mar 20, 2023
ce7b912
fix: fix DEFAULT_OPTIONS being destructured incorrectly in Line
ManpreetSL Mar 23, 2023
30c018b
feat: assign default values to Line props
ManpreetSL Mar 23, 2023
3b7d463
refactor: update line lib file to fix errors in Overlay Line
ManpreetSL Mar 29, 2023
e6a5c54
build: add @presenter/contract as a dependency
ManpreetSL Mar 29, 2023
0b21c79
refactor: change HotkeyDialog components to TS
ManpreetSL Mar 29, 2023
df7c94e
refactor: update Translations and sortBy types to match
ManpreetSL Mar 29, 2023
337884c
refactor: remove unneeded Number casting in sortBy function
ManpreetSL Mar 29, 2023
280262c
refactor: add onClick() to ButtonProps type
ManpreetSL Mar 29, 2023
7579c3b
build: add a TypeScript types script
ManpreetSL Nov 5, 2023
a91a1c2
refactor: rearrange imports in zoom service using ESLint
ManpreetSL Nov 5, 2023
0c31558
refactor: update Bookmarks register prop type
ManpreetSL Nov 5, 2023
517ac95
refactor: update NavigatorLine and Bar prop types to TS
ManpreetSL Nov 5, 2023
a7c9349
refactor: add default Shabad object if other sources are nullish
ManpreetSL Nov 5, 2023
0124186
refactor update NavigatorHotkeys types
ManpreetSL Nov 5, 2023
1917422
refactor: update NavigationHotkeys types
ManpreetSL Nov 5, 2023
552308e
refactor: update ResultProps
ManpreetSL Nov 5, 2023
a577f7e
refactor: add contract types into hooks lib
ManpreetSL Nov 5, 2023
c5cb89e
remove UnwrapModel from contract data types
ManpreetSL Nov 5, 2023
59fdf60
refactor: add types to options lib
ManpreetSL Nov 5, 2023
6a6fb7e
refactor: add types to util lib
ManpreetSL Nov 5, 2023
7161abe
fix: fix no floating promises ESLint errors using void operator
ManpreetSL Nov 5, 2023
82d5a1a
refactor: add types and default value to typeId in Overlay
ManpreetSL Nov 6, 2023
af9b1e0
refactor: update Presenter Display types
ManpreetSL Nov 6, 2023
9e02c1f
refactor: add type for About state
ManpreetSL Nov 6, 2023
94f61f6
style: add trailing comma
ManpreetSL Nov 6, 2023
d05f2ce
refactor: update DynamicOptions types
ManpreetSL Nov 6, 2023
a590bf3
refactor: make some DropdownProps properties optional
ManpreetSL Nov 6, 2023
cfd92de
refactor: remove unused prop types imports
ManpreetSL Nov 6, 2023
c51e3ee
refactor: remove unused prop types imports
ManpreetSL Nov 8, 2023
e435c52
build: update @presenter/contract version to wildcard
ManpreetSL Nov 29, 2023
6714dfb
refactor: use void operator on analytics' initialise() call
ManpreetSL Nov 29, 2023
5e0a085
refactor: extract types to GlobalHotKeysProps
ManpreetSL Nov 29, 2023
43085ac
refactor: change toString() to toDateString()
ManpreetSL Nov 30, 2023
99e81d1
refactor: remove null checking of type's value
ManpreetSL Nov 30, 2023
2f98f06
refactor: simplify DisplayProps type by picking from ClientSettings type
ManpreetSL Nov 30, 2023
21a4899
refactor: remove default lineId value and add string type
ManpreetSL Nov 30, 2023
64acae3
refactor: simplify componentDidUpdate param type
ManpreetSL Nov 30, 2023
d5cf1ab
refactor: update line types in Display
ManpreetSL Nov 30, 2023
e965fac
refactor: remove default value assignment of Shabad properties
ManpreetSL Nov 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"homepage": "https://github.com/shabados/presenter#readme",
"dependencies": {
"@electron/remote": "^2.0.8",
"@presenter/contract": "file:../../packages/contract",
"@presenter/contract": "*",
"@presenter/node": "file:../../packages/node",
"@presenter/swiss-knife": "file:../../packages/swiss-knife",
"@sentry/node": "^6.19.7",
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/services/zoom.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//! To be refactored into shared utilities - @shabados/transformers?
import { Line, Shabad } from '@presenter/contract'
import { mutableCounter, mutableValue } from '@presenter/node/src/mutable-value'
import { LANGUAGES, TRANSLATION_ORDER, TRANSLITERATION_ORDER } from '@shabados/frontend/src/lib/data'
import { customiseLine, getTranslations, getTransliterators } from '@shabados/frontend/src/lib/line'
import { stripVishraams, toUnicode } from 'gurmukhi-utils'
import { mapValues } from 'lodash'
import Url from 'url-parse'

import fetch from '../helpers/fetch'
import { mutableCounter, mutableValue } from '@presenter/node/src/mutable-value'
import { getSources, GetSourcesResult } from './database'
import settings from '../settings'
import { getSources, GetSourcesResult } from './database'

const prepareSecondary = ( data, sorter ) => Object
.entries( data )
Expand Down
6 changes: 4 additions & 2 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"start": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint ."
"lint": "eslint .",
"types": "tsc --noEmit"
},
"devDependencies": {
"@types/lodash": "^4.14.182",
Expand All @@ -56,6 +57,7 @@
"@types/scroll-into-view": "^1.16.0",
"@vitejs/plugin-react": "^1.3.2",
"source-map-explorer": "^2.5.2",
"vite": "^2.9.8"
"vite": "^2.9.8",
"@presenter/contract": "file:/../../packages/contract"
ManpreetSL marked this conversation as resolved.
Show resolved Hide resolved
}
}
28 changes: 16 additions & 12 deletions apps/frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import './App.css'

import { RecommendedSources, Shabad, Writer } from '@presenter/contract'
import classNames from 'classnames'
import { SnackbarProvider } from 'notistack'
import { ElementType, lazy, PureComponent, ReactNode, Suspense } from 'react'
Expand Down Expand Up @@ -48,7 +49,7 @@ class App extends PureComponent {
transitionHistory: {},
latestLines: {},
shabad: null,
recommendedSources: {},
recommendedSources: {} as RecommendedSources['recommendedSources'],
writers: {},
settings: loadSettings(),
next: {},
Expand All @@ -71,19 +72,19 @@ class App extends PureComponent {
controller.on( 'settings', this.onSettings )

// Get recommended sources and set as settings, if there are none
fetch( `${BACKEND_URL}/sources` )
void fetch( `${BACKEND_URL}/sources` )
.then( ( res ) => res.json() )
.then( ( { recommendedSources } ) => {
.then( ( { recommendedSources }: { recommendedSources: RecommendedSources['recommendedSources'] } ) => {
//* Update default options and settings with fetched recommended sources
DEFAULT_OPTIONS.local.sources = recommendedSources
//! Re-load settings since we've modified DEFAULT_OPTIONS directly
this.setState( { recommendedSources, settings: loadSettings() } )
} )

// Get writers
fetch( `${BACKEND_URL}/writers` )
void fetch( `${BACKEND_URL}/writers` )
.then( ( res ) => res.json() )
.then( ( { writers } ) => this.setState( { writers } ) )
.then( ( { writers }: { writers: Writer[] } ) => this.setState( { writers } ) )
}

componentWillUnmount() {
Expand Down Expand Up @@ -112,9 +113,11 @@ class App extends PureComponent {

onDisconnected = () => this.setState( { connected: false } )

onShabad = ( shabad: any ) => this.setState( { next: { shabad, bani: null } } )
onShabad = ( shabad: Shabad ) => this.setState( { next: { shabad, bani: null } } )

onLine = ( lineId: string ) => this.setState( ( { next }: any ) => ( { lineId, ...next, next: {} } ) )
onLine = ( lineId: string ) => this.setState(
( { next }: any ) => ( { lineId, ...next, next: {} } )
)

onViewedLines = ( viewedLines: any[] ) => this.setState( { viewedLines } )

Expand Down Expand Up @@ -179,11 +182,12 @@ class App extends PureComponent {
[ RecommendedSourcesContext.Provider, recommendedSources ],
[ ContentContext.Provider, { bani, shabad, lineId, mainLineId, nextLineId } ],
[ SnackbarProvider ],
] as [ElementType, any][] ).reduce( ( withContexts, [ Provider, value ] ) => ( children ) => withContexts(
<Provider value={value}>
{children}
</Provider>,
), ( context: ReactNode ) => context )
] as [ElementType, any][] )
.reduce( ( withContexts, [ Provider, value ] ) => ( children ) => withContexts(
<Provider value={value}>
{children}
</Provider>,
), ( context: ReactNode ) => context )

return withContexts(
<div className={classNames( { mobile: isMobile, tablet: isTablet, desktop: isDesktop }, 'app' )}>
Expand Down
3 changes: 1 addition & 2 deletions apps/frontend/src/Controller/Bookmarks.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import './Bookmarks.css'

import { List, ListItem } from '@mui/material'
import { func, number } from 'prop-types'
import { useContext } from 'react'

import { BookmarksContext } from '../lib/contexts'
Expand All @@ -11,7 +10,7 @@ import { withNavigationHotkeys } from '../shared/NavigationHotkeys'

type BookmarkProps = {
focused?: number,
register: (index: number, ref: HTMLElement) => void,
register: ( index: number, ref: HTMLElement | null ) => void,
}

const Bookmarks = ( { register, focused = 0 }: BookmarkProps ) => {
Expand Down
3 changes: 1 addition & 2 deletions apps/frontend/src/Controller/History.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import List from '@mui/material/List'
import ListItem from '@mui/material/ListItem'
import ListItemIcon from '@mui/material/ListItemIcon'
import { stripVishraams } from 'gurmukhi-utils'
import { func, number } from 'prop-types'
import { useContext, useMemo } from 'react'

import { HISTORY_DOWNLOAD_URL } from '../lib/consts'
Expand All @@ -20,7 +19,7 @@ import { withNavigationHotkeys } from '../shared/NavigationHotkeys'

type HistoryProps = {
focused?: number,
register: (index: number, ref: HTMLElement) => void,
register: ( index: number, ref: HTMLElement ) => void,
}

const History = ( { register, focused = 0 }: HistoryProps ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import ListItem from '@mui/material/ListItem'
import classNames from 'classnames'
import { stripVishraams } from 'gurmukhi-utils'
import { invert } from 'lodash'
import { bool, func, string } from 'prop-types'
import { useCallback, useContext, useEffect, useMemo, useState } from 'react'
import { Navigate, useLocation } from 'react-router-dom'

Expand All @@ -33,6 +32,17 @@ import NavigatorHotKeys from '../shared/NavigatorHotkeys'
import ShabadInfo from './ShabadInfo'
import ToolbarButton from './ToolbarButton'

type NavigatorLineProps = {
register: ( id, line, ) => any,
gurmukhi: string,
focused: boolean,
next: boolean,
main: boolean,
id: string,
hotkey?: string | null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type here is undefined | string | null - do we actually need the null value? Coupled with the null assignment on L57, that may be a change in semantics!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was directly translated from what was there before - defaultProps assigned null to hotkey, and it also wasn't marked with isRequired, hence the optional marker here. Would you like me to change this?

And also, this is something I encountered in .SHIFT, too. If I remove the optional property from hotkey here, if you don't pass a value to hotkey when creating the NavigatorLine component, then it gives this error:

Property 'hotkey' is missing in type '{ focused: boolean; main: boolean; next: boolean; register: () => any; timestamp: any; QueryBuilderType: LinesBuilder; id: string; shabadId: string; sourcePage: number; sourceLine: number; ... 11 more ...; key: string; }' but required in type 'NavigatorLineProps'.ts(2741)

So with TypeScript, how do you factor in default values like this without making the param optional?

timestamp?: string | null,
}

/**
* Line component that attaches click handlers.
* @param gurmukhi The Gurmukhi for the line to render.
Expand All @@ -44,11 +54,11 @@ const NavigatorLine = ( {
register,
focused,
gurmukhi,
hotkey,
hotkey = null,
main,
next,
timestamp,
} ) => {
timestamp = null,
}: NavigatorLineProps ) => {
// Move to the line id on click
const onClick = () => controller.line( id )

Expand Down Expand Up @@ -83,27 +93,19 @@ const NavigatorLine = ( {
)
}

NavigatorLine.propTypes = {
register: func.isRequired,
gurmukhi: string.isRequired,
focused: bool.isRequired,
next: bool.isRequired,
main: bool.isRequired,
id: string.isRequired,
hotkey: string,
timestamp: string,
}

NavigatorLine.defaultProps = {
hotkey: null,
timestamp: null,
type NavigatorProps = {
updateFocus: () => any,
register: () => any,
focused?: string,
}

/**
* Navigator Component.
* Displays lines from Shabad and allows navigation.
*/
const Navigator = ( { updateFocus, register, focused } ) => {
const Navigator = ( {
updateFocus, register, focused,
}: NavigatorProps ) => {
const location = useLocation()

const { viewedLines } = useContext( HistoryContext )
Expand Down Expand Up @@ -160,16 +162,6 @@ const Navigator = ( { updateFocus, register, focused } ) => {
)
}

Navigator.propTypes = {
updateFocus: func.isRequired,
register: func.isRequired,
focused: string,
}

Navigator.defaultProps = {
focused: undefined,
}

const NavigatorNavigationHotkeys = withNavigationHotkeys( {
arrowKeys: true,
lineKeys: true,
Expand All @@ -190,10 +182,14 @@ const NavigatorWithAllHotKeys = ( props ) => (

export default NavigatorWithAllHotKeys

type BarProps = {
onHover: ( text: string | null ) => Record<string, any>,
}

/**
* Used by Menu parent to render content in the bottom bar.
*/
export const Bar = ( { onHover } ) => {
export const Bar = ( { onHover }: BarProps ) => {
const [ autoSelectHover, setAutoSelectHover ] = useState( false )

const content = useContext( ContentContext )
Expand Down Expand Up @@ -292,11 +288,3 @@ export const Bar = ( { onHover } ) => {
</div>
)
}

Bar.propTypes = {
onHover: func,
}

Bar.defaultProps = {
onHover: () => {},
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import { ListItem } from '@mui/material'
import classNames from 'classnames'
import { arrayOf, bool, func, number, shape, string } from 'prop-types'
import { forwardRef, useContext } from 'react'

import { RecommendedSourcesContext, SettingsContext, WritersContext } from '../../lib/contexts'
import controller from '../../lib/controller'
import { LANGUAGE_NAMES, SOURCE_ABBREVIATIONS, TRANSLITERATORS } from '../../lib/data'
import { customiseLine, getTranslation } from '../../lib/line'

type ResultProps = {
gurmukhi: string,
id: string,
typeId: number,
shabadId: string,
focused: boolean,
highlighter: ( {}: { gurmukhi: string } ) => any,
sourceId: number,
shabad: Record<string, any>,
sourcePage: number,
translations: { [translation: string]: string }[],
}

/**
* Renders a single result, highlighting the match.
* @param {string} gurmukhi The shabad line to display.
Expand All @@ -33,7 +45,7 @@ const Result = forwardRef( ( {
highlighter,
sourcePage,
translations,
}, ref ) => {
}: ResultProps, ref ) => {
const { local: {
sources,
search: {
Expand Down Expand Up @@ -116,17 +128,4 @@ const Result = forwardRef( ( {
)
} )

Result.propTypes = {
gurmukhi: string.isRequired,
id: string.isRequired,
typeId: number.isRequired,
shabadId: string.isRequired,
focused: bool.isRequired,
highlighter: func.isRequired,
sourceId: number.isRequired,
shabad: shape( { } ).isRequired,
sourcePage: number.isRequired,
translations: arrayOf( shape( { translation: string.isRequired } ) ).isRequired,
}

export default Result
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { faTimes } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { IconButton, Input, InputAdornment, List } from '@mui/material'
import classNames from 'classnames'
import { func, number, oneOfType, string } from 'prop-types'
import { stringify } from 'querystring'
import { useCallback, useContext, useEffect, useRef, useState } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
Expand Down Expand Up @@ -41,12 +40,18 @@ const getSearchParams = ( searchQuery ) => {
return { anchor, value, type }
}

type SearchProps = {
updateFocus?: () => any,
register?: () => any,
focused?: string | number,
}

/**
* Search Component.
* Converts ASCII to unicode on input.
* Displays results.
*/
const Search = ( { updateFocus, register, focused } ) => {
const Search = ( { updateFocus, register, focused }: SearchProps ) => {
const { local: {
search: {
showResultCitations,
Expand Down Expand Up @@ -199,16 +204,6 @@ const Search = ( { updateFocus, register, focused } ) => {
)
}

Search.propTypes = {
focused: oneOfType( [ string, number ] ),
register: func.isRequired,
updateFocus: func.isRequired,
}

Search.defaultProps = {
focused: undefined,
}

export default withNavigationHotkeys( {
keymap: {
next: [ 'down', 'tab' ],
Expand Down
5 changes: 3 additions & 2 deletions apps/frontend/src/Controller/ToolbarButton.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { FontAwesomeIcon, FontAwesomeIconProps } from '@fortawesome/react-fontawesome'
import { IconProp } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import IconButton from '@mui/material/IconButton'

type ToolbarButtonProps = {
name: string,
icon: FontAwesomeIconProps,
icon: IconProp,
className?: string,
onClick?: () => void,
onMouseEnter?: () => void,
Expand Down