chore: enable noUncheckedIndexedAccess, better type check (#2608)

This commit is contained in:
Stephen Zhou
2025-01-18 22:35:23 +08:00
committed by GitHub
parent f947bd1d1e
commit 2cd1b5daf9
182 changed files with 489 additions and 589 deletions
@@ -33,7 +33,7 @@ export function PickerIos<T>({
const [currentValue, setCurrentValue] = useState(() => {
if (!value) {
return options[0].value
return options[0]!.value
}
return value
})
@@ -31,7 +31,7 @@ export function Select<T>({
}: SelectProps<T>) {
const [currentValue, setCurrentValue] = useState(() => {
if (!value) {
return options[0].value
return options[0]!.value
}
return value
})
@@ -65,7 +65,7 @@ export function Select<T>({
}))}
onPress={(e) => {
const { index } = e.nativeEvent
handleChangeValue(options[index].value)
handleChangeValue(options[index]!.value)
}}
>
<View
@@ -28,7 +28,7 @@ export const FallbackIcon = ({
const [, , , bgAccent, bgAccentLight, bgAccentUltraLight] = colors
const renderedText = useMemo(() => {
const isCJK = isCJKChar(title[0])
const isCJK = isCJKChar(title[0]!)
return (
<Text style={StyleSheet.flatten([styles.text, textStyle])} className={textClassName}>
{isCJK ? title[0] : title.slice(0, 2)}
@@ -39,7 +39,7 @@ export const FallbackIcon = ({
return (
<LinearGradient
className={className}
colors={[bgAccent, bgAccentLight, bgAccentUltraLight]}
colors={[bgAccent!, bgAccentLight!, bgAccentUltraLight!]}
locations={[0, 0.99, 1]}
style={[sizeStyle, styles.container, style]}
>
@@ -112,11 +112,11 @@ export const TabBar = forwardRef<ScrollView, TabBarProps>(
indicatorPosition.value = withSpring(tabPositions[currentTab] || 0, springConfig)
if (tabRef.current) {
const x = currentTab > 0 ? tabPositions[currentTab - 1] + tabWidths[currentTab - 1] : 0
const x = currentTab > 0 ? tabPositions[currentTab - 1]! + tabWidths[currentTab - 1]! : 0
const isCurrentTabVisible =
sharedPagerOffsetX.value < tabPositions[currentTab] &&
sharedPagerOffsetX.value + tabWidths[currentTab] > tabPositions[currentTab]
sharedPagerOffsetX.value < tabPositions[currentTab]! &&
sharedPagerOffsetX.value + tabWidths[currentTab]! > tabPositions[currentTab]!
if (!isCurrentTabVisible) {
tabRef.current.scrollTo({ x, y: 0, animated: true })
@@ -146,17 +146,17 @@ export const TabBar = forwardRef<ScrollView, TabBarProps>(
// Interpolate between current and next tab positions
const xPosition =
tabPositions[currentIndex] +
(tabPositions[nextIndex] - tabPositions[currentIndex]) * progress
tabPositions[currentIndex]! +
(tabPositions[nextIndex]! - tabPositions[currentIndex]!) * progress
// Interpolate between current and next tab widths
const width =
tabWidths[currentIndex] + (tabWidths[nextIndex] - tabWidths[currentIndex]) * progress
tabWidths[currentIndex]! + (tabWidths[nextIndex]! - tabWidths[currentIndex]!) * progress
return {
transform: [{ translateX: Math.max(xPosition, 0) }],
width,
backgroundColor: tabs[currentTab].activeColor || accentColor,
backgroundColor: tabs[currentTab]!.activeColor || accentColor,
}
})
@@ -64,14 +64,14 @@ export class ToastManager {
}
private scheduleDismiss(index: number) {
const props = this.propsMap[index]
const props = this.propsMap[index]!
if (props.duration === Infinity) {
return
}
setTimeout(async () => {
await this.toastRefs[index].dimiss()
await this.toastRefs[index]!.dimiss()
this.remove(index)
}, props.duration)
}