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
@@ -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)
}}
/>
)