chore: enable noUncheckedIndexedAccess, better type check (#2608)
This commit is contained in:
@@ -25,7 +25,7 @@ export const RecommendationListItem: FC<{
|
||||
const maintainers = new Set<string>()
|
||||
const categories = new Set<string>()
|
||||
for (const route in data.routes) {
|
||||
const routeData = data.routes[route]
|
||||
const routeData = data.routes[route]!
|
||||
if (routeData.maintainers) {
|
||||
routeData.maintainers.forEach((m) => maintainers.add(m))
|
||||
}
|
||||
@@ -120,7 +120,7 @@ export const RecommendationListItem: FC<{
|
||||
/>
|
||||
<View className="absolute inset-2 items-center justify-center" pointerEvents="none">
|
||||
<Text ellipsizeMode="middle" numberOfLines={1} className="text-text whitespace-pre">
|
||||
{data.routes[route].name}
|
||||
{data.routes[route]!.name}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -75,11 +75,11 @@ const Tab: TabComponent = ({ tab, ...rest }) => {
|
||||
return []
|
||||
}
|
||||
return Object.keys(data).sort((a, b) => {
|
||||
const aname = data[a].name
|
||||
const bname = data[b].name
|
||||
const aname = data[a]!.name
|
||||
const bname = data[b]!.name
|
||||
|
||||
const aRouteName = data[a].routes[Object.keys(data[a].routes)[0]].name
|
||||
const bRouteName = data[b].routes[Object.keys(data[b].routes)[0]].name
|
||||
const aRouteName = data[a]!.routes[Object.keys(data[a]!.routes)[0]!]!.name
|
||||
const bRouteName = data[b]!.routes[Object.keys(data[b]!.routes)[0]!]!.name
|
||||
|
||||
const ia = isASCII(aname) && isASCII(aRouteName)
|
||||
const ib = isASCII(bname) && isASCII(bRouteName)
|
||||
@@ -98,7 +98,7 @@ const Tab: TabComponent = ({ tab, ...rest }) => {
|
||||
const groups = keys.reduce(
|
||||
(acc, key) => {
|
||||
// A-Z -> A-Z, 0-9 -> #, other -> #, # push to the end
|
||||
const firstChar = key[0].toUpperCase()
|
||||
const firstChar = key[0]!.toUpperCase()
|
||||
if (/[A-Z]/.test(firstChar)) {
|
||||
acc[firstChar] = acc[firstChar] || []
|
||||
acc[firstChar].push(key)
|
||||
@@ -127,7 +127,7 @@ const Tab: TabComponent = ({ tab, ...rest }) => {
|
||||
if (!data) {
|
||||
continue
|
||||
}
|
||||
result.push({ key: item, data: data[item] })
|
||||
result.push({ key: item, data: data[item]! })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ const NavigationSidebar: FC<{
|
||||
(letter: string, animated = true) => {
|
||||
const index = alphabetGroups.findIndex((group) => {
|
||||
if (typeof group !== "string") return false
|
||||
const firstChar = group[0].toUpperCase()
|
||||
const firstChar = group[0]!.toUpperCase()
|
||||
const firstCharIsAlphabet = /[A-Z]/.test(firstChar)
|
||||
if (firstCharIsAlphabet) {
|
||||
return firstChar === letter
|
||||
@@ -233,7 +233,7 @@ const NavigationSidebar: FC<{
|
||||
return
|
||||
}
|
||||
|
||||
const firstChar = letter[0].toUpperCase()
|
||||
const firstChar = letter[0]!.toUpperCase()
|
||||
const firstCharIsAlphabet = /[A-Z]/.test(firstChar)
|
||||
if (firstCharIsAlphabet) {
|
||||
scrollToLetter(letter, false)
|
||||
|
||||
@@ -20,7 +20,7 @@ export const SearchTabBar: FC<{
|
||||
tabs={SearchTabs}
|
||||
currentTab={SearchTabs.findIndex((tab) => tab.value === searchType)}
|
||||
onTabItemPress={(index) => {
|
||||
setSearchType(SearchTabs[index].value as SearchType)
|
||||
setSearchType(SearchTabs[index]!.value as SearchType)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -199,7 +199,7 @@ const CategoryGrouped = memo(
|
||||
const SubscriptionItem = memo(({ id, className }: { id: string; className?: string }) => {
|
||||
const subscription = useSubscription(id)
|
||||
const unreadCount = useUnreadCount(id)
|
||||
const feed = useFeed(id)
|
||||
const feed = useFeed(id)!
|
||||
const inGrouped = !!useContext(GroupedContext)
|
||||
const view = useCurrentView()
|
||||
const { isLoading } = usePrefetchFeed(id, { enabled: !feed })
|
||||
|
||||
@@ -50,7 +50,7 @@ export function FollowFeed(props: { id: string }) {
|
||||
function FollowImpl() {
|
||||
const { id } = useLocalSearchParams()
|
||||
|
||||
const feed = useFeed(id as string)
|
||||
const feed = useFeed(id as string)!
|
||||
const isSubscribed = useSubscriptionByFeedId(feed?.id || "")
|
||||
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
|
||||
@@ -96,7 +96,7 @@ const TeamsCheckBox = forwardRef<
|
||||
const runAnimation = (index: number) => {
|
||||
"worklet"
|
||||
if (index < animations.length) {
|
||||
shakeSharedValue.value = withTiming(animations[index], { duration: 100 }, () => {
|
||||
shakeSharedValue.value = withTiming(animations[index]!, { duration: 100 }, () => {
|
||||
runAnimation(index + 1)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export function SocialLogin() {
|
||||
{Object.keys(provider)
|
||||
.filter((key) => key !== "apple" || (Platform.OS === "ios" && key === "apple"))
|
||||
.map((key) => {
|
||||
const providerInfo = provider[key]
|
||||
const providerInfo = provider[key]!
|
||||
return (
|
||||
<TouchableOpacity
|
||||
key={key}
|
||||
|
||||
@@ -38,11 +38,11 @@ export const ViewTab = () => {
|
||||
indicatorPosition.value = withSpring(tabPositions[currentView] || 0, springConfig)
|
||||
|
||||
if (tabRef.current) {
|
||||
const x = currentView > 0 ? tabPositions[currentView - 1] + tabWidths[currentView - 1] : 0
|
||||
const x = currentView > 0 ? tabPositions[currentView - 1]! + tabWidths[currentView - 1]! : 0
|
||||
|
||||
const isCurrentTabVisible =
|
||||
scrollOffsetX.current < tabPositions[currentView] &&
|
||||
scrollOffsetX.current + tabWidths[currentView] > tabPositions[currentView]
|
||||
scrollOffsetX.current < tabPositions[currentView]! &&
|
||||
scrollOffsetX.current + tabWidths[currentView]! > tabPositions[currentView]!
|
||||
|
||||
if (!isCurrentTabVisible) {
|
||||
tabRef.current.scrollTo({ x, y: 0, animated: true })
|
||||
@@ -58,7 +58,7 @@ export const ViewTab = () => {
|
||||
translateX: indicatorPosition.value + 10 + Math.abs(offset),
|
||||
},
|
||||
],
|
||||
backgroundColor: views[currentView].activeColor,
|
||||
backgroundColor: views[currentView]!.activeColor,
|
||||
width: (tabWidths[currentView] || 20) - 40 + Math.abs(offset),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -46,7 +46,7 @@ import { GroupedContext, useViewPageCurrentView } from "../ctx"
|
||||
export const SubscriptionItem = memo(({ id, className }: { id: string; className?: string }) => {
|
||||
const subscription = useSubscription(id)
|
||||
const unreadCount = useUnreadCount(id)
|
||||
const feed = useFeed(id)
|
||||
const feed = useFeed(id)!
|
||||
const inGrouped = !!useContext(GroupedContext)
|
||||
const view = useViewPageCurrentView()
|
||||
const { isLoading } = usePrefetchFeed(id, { enabled: !subscription && !feed })
|
||||
|
||||
Reference in New Issue
Block a user