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,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
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue