Fix a bunch of type errors and add a type-check to the github workflows (#837)
* Add yarn type-check * Rename to yarn typecheck * Fix a collection of type errors * Add typecheck to automated tests * add `dist` to exluded folders tsconfig --------- Co-authored-by: Ansh Nanda <anshnanda10@gmail.com>
This commit is contained in:
parent
46c9de7c18
commit
e8843ded5b
23 changed files with 168 additions and 82 deletions
|
@ -1,5 +1,6 @@
|
|||
import {useState, useEffect} from 'react'
|
||||
import {useStores} from 'state/index'
|
||||
import {ImageModel} from 'state/models/media/image'
|
||||
import * as apilib from 'lib/api/index'
|
||||
import {getLinkMeta} from 'lib/link-meta/link-meta'
|
||||
import {getPostAsQuote, getFeedAsEmbed} from 'lib/link-meta/bsky'
|
||||
|
@ -90,7 +91,9 @@ export function useExternalLinkFetch({
|
|||
setExtLink({
|
||||
...extLink,
|
||||
isLoading: false, // done
|
||||
localThumb,
|
||||
localThumb: localThumb
|
||||
? new ImageModel(store, localThumb)
|
||||
: undefined,
|
||||
})
|
||||
})
|
||||
return cleanup
|
||||
|
|
|
@ -27,14 +27,14 @@ export const Lightbox = observer(function Lightbox() {
|
|||
}
|
||||
|
||||
let altText = ''
|
||||
let uri
|
||||
let uri = ''
|
||||
if (lightbox.name === 'images') {
|
||||
const opts = store.shell.activeLightbox as models.ImagesLightbox
|
||||
const opts = lightbox as models.ImagesLightbox
|
||||
uri = opts.images[imageIndex].uri
|
||||
altText = opts.images[imageIndex].alt
|
||||
} else if (store.shell.activeLightbox.name === 'profile-image') {
|
||||
const opts = store.shell.activeLightbox as models.ProfileImageLightbox
|
||||
uri = opts.profileView.avatar
|
||||
altText = opts.images[imageIndex].alt || ''
|
||||
} else if (lightbox.name === 'profile-image') {
|
||||
const opts = lightbox as models.ProfileImageLightbox
|
||||
uri = opts.profileView.avatar || ''
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -44,11 +44,11 @@ export function Component({
|
|||
const {track} = useAnalytics()
|
||||
|
||||
const [isProcessing, setProcessing] = useState<boolean>(false)
|
||||
const [name, setName] = useState<string>(list?.list.name || '')
|
||||
const [name, setName] = useState<string>(list?.list?.name || '')
|
||||
const [description, setDescription] = useState<string>(
|
||||
list?.list.description || '',
|
||||
list?.list?.description || '',
|
||||
)
|
||||
const [avatar, setAvatar] = useState<string | undefined>(list?.list.avatar)
|
||||
const [avatar, setAvatar] = useState<string | undefined>(list?.list?.avatar)
|
||||
const [newAvatar, setNewAvatar] = useState<RNImage | undefined | null>()
|
||||
|
||||
const onPressCancel = useCallback(() => {
|
||||
|
@ -59,7 +59,7 @@ export function Component({
|
|||
async (img: RNImage | null) => {
|
||||
if (!img) {
|
||||
setNewAvatar(null)
|
||||
setAvatar(null)
|
||||
setAvatar(undefined)
|
||||
return
|
||||
}
|
||||
track('CreateMuteList:AvatarSelected')
|
||||
|
|
|
@ -36,7 +36,7 @@ export const Component = observer(
|
|||
const pal = usePalette('default')
|
||||
const palPrimary = usePalette('primary')
|
||||
const palInverted = usePalette('inverted')
|
||||
const [selected, setSelected] = React.useState([])
|
||||
const [selected, setSelected] = React.useState<string[]>([])
|
||||
|
||||
const listsList: ListsListModel = React.useMemo(
|
||||
() => new ListsListModel(store, store.me.did),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React from 'react'
|
||||
import * as React from 'react'
|
||||
import {StyleSheet, View} from 'react-native'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {AppBskyActorDefs} from '@atproto/api'
|
||||
|
@ -32,7 +32,9 @@ export const ProfileCard = observer(
|
|||
noBorder?: boolean
|
||||
followers?: AppBskyActorDefs.ProfileView[] | undefined
|
||||
overrideModeration?: boolean
|
||||
renderButton?: (profile: AppBskyActorDefs.ProfileViewBasic) => JSX.Element
|
||||
renderButton?: (
|
||||
profile: AppBskyActorDefs.ProfileViewBasic,
|
||||
) => React.ReactNode
|
||||
}) => {
|
||||
const store = useStores()
|
||||
const pal = usePalette('default')
|
||||
|
|
|
@ -587,9 +587,9 @@ const styles = StyleSheet.create({
|
|||
// Word wrapping appears fine on
|
||||
// mobile but overflows on desktop
|
||||
handle: isNative
|
||||
? undefined
|
||||
? {}
|
||||
: {
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore web only -prf
|
||||
wordBreak: 'break-all',
|
||||
},
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ export const BlurView = ({
|
|||
}: React.PropsWithChildren<BlurViewProps>) => {
|
||||
// @ts-ignore using an RNW-specific attribute here -prf
|
||||
let blur = `blur(${blurAmount || 10}px`
|
||||
// @ts-ignore using an RNW-specific attribute here -prf
|
||||
style = addStyle(style, {backdropFilter: blur, WebkitBackdropFilter: blur})
|
||||
if (blurType === 'dark') {
|
||||
style = addStyle(style, styles.dark)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React from 'react'
|
||||
import * as React from 'react'
|
||||
import {StyleSheet, View} from 'react-native'
|
||||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
import {Text} from './text/Text'
|
||||
|
@ -10,6 +10,15 @@ import {isDesktopWeb} from 'platform/detection'
|
|||
* DSL. See for instance /locale/en/privacy-policy.tsx
|
||||
*/
|
||||
|
||||
interface IsChildProps {
|
||||
isChild?: boolean
|
||||
}
|
||||
|
||||
// type ReactNodeWithIsChildProp =
|
||||
// | React.ReactElement<IsChildProps>
|
||||
// | React.ReactElement<IsChildProps>[]
|
||||
// | React.ReactNode
|
||||
|
||||
export function H1({children}: React.PropsWithChildren<{}>) {
|
||||
const pal = usePalette('default')
|
||||
return (
|
||||
|
@ -55,10 +64,7 @@ export function P({children}: React.PropsWithChildren<{}>) {
|
|||
)
|
||||
}
|
||||
|
||||
export function UL({
|
||||
children,
|
||||
isChild,
|
||||
}: React.PropsWithChildren<{isChild: boolean}>) {
|
||||
export function UL({children, isChild}: React.PropsWithChildren<IsChildProps>) {
|
||||
return (
|
||||
<View style={[styles.ul, isChild && styles.ulChild]}>
|
||||
{markChildProps(children)}
|
||||
|
@ -66,10 +72,7 @@ export function UL({
|
|||
)
|
||||
}
|
||||
|
||||
export function OL({
|
||||
children,
|
||||
isChild,
|
||||
}: React.PropsWithChildren<{isChild: boolean}>) {
|
||||
export function OL({children, isChild}: React.PropsWithChildren<IsChildProps>) {
|
||||
return (
|
||||
<View style={[styles.ol, isChild && styles.olChild]}>
|
||||
{markChildProps(children)}
|
||||
|
@ -122,10 +125,13 @@ export function EM({children}: React.PropsWithChildren<{}>) {
|
|||
)
|
||||
}
|
||||
|
||||
function markChildProps(children) {
|
||||
function markChildProps(children: React.ReactNode) {
|
||||
return React.Children.map(children, child => {
|
||||
if (React.isValidElement(child)) {
|
||||
return React.cloneElement(child, {isChild: true})
|
||||
return React.cloneElement<IsChildProps>(
|
||||
child as React.ReactElement<IsChildProps>,
|
||||
{isChild: true},
|
||||
)
|
||||
}
|
||||
return child
|
||||
})
|
||||
|
|
|
@ -70,7 +70,9 @@ export function UserInfoText({
|
|||
numberOfLines={1}
|
||||
href={`/profile/${profile.handle}`}
|
||||
text={`${prefix || ''}${sanitizeDisplayName(
|
||||
profile[attr] || profile.handle,
|
||||
typeof profile[attr] === 'string' && profile[attr]
|
||||
? (profile[attr] as string)
|
||||
: profile.handle,
|
||||
)}`}
|
||||
/>
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue