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
@@ -137,7 +137,7 @@ export const useEntriesByView = ({
const groupByDate = useGeneralSettingKey("groupByDate")
const groupedCounts: number[] | undefined = useMemo(() => {
if (views[view].gridMode) {
if (views[view]!.gridMode) {
return
}
if (!groupByDate) {
@@ -184,8 +184,11 @@ function sortEntriesIdByEntryPublishedAt(entries: string[]) {
const entriesId2Map = entryActions.getFlattenMapEntries()
return entries
.slice()
.sort((a, b) =>
entriesId2Map[b]?.entries.publishedAt.localeCompare(entriesId2Map[a]?.entries.publishedAt),
.sort(
(a, b) =>
entriesId2Map[b]?.entries.publishedAt.localeCompare(
entriesId2Map[a]?.entries.publishedAt!,
) || 0,
)
}
@@ -203,8 +206,10 @@ function sortEntriesIdByEntryInsertedAt(entries: string[]) {
const entriesId2Map = entryActions.getFlattenMapEntries()
return entries
.slice()
.sort((a, b) =>
entriesId2Map[b]?.entries.insertedAt.localeCompare(entriesId2Map[a]?.entries.insertedAt),
.sort(
(a, b) =>
entriesId2Map[b]?.entries.insertedAt.localeCompare(entriesId2Map[a]?.entries.insertedAt!) ||
0,
)
}
@@ -217,7 +222,7 @@ const useFetchEntryContentByStream = (remoteEntryIds?: string[]) => {
const nextIds = [] as string[]
if (onlyNoStored) {
for (const id of remoteEntryIds) {
const entry = getEntry(id)
const entry = getEntry(id)!
if (entry.entries.content) {
continue
}
@@ -253,8 +258,8 @@ const useFetchEntryContentByStream = (remoteEntryIds?: string[]) => {
// Process all complete lines
for (let i = 0; i < lines.length - 1; i++) {
if (lines[i].trim()) {
const json = JSON.parse(lines[i])
if (lines[i]!.trim()) {
const json = JSON.parse(lines[i]!)
// Handle each JSON line here
entryActions.updateEntryContent(json.id, json.content)
}
@@ -29,7 +29,7 @@ export const useEntryMarkReadHandler = (entriesIds: string[]) => {
)
return useMemo(() => {
if (views[feedView].wideMode && renderAsRead) {
if (views[feedView]!.wideMode && renderAsRead) {
return handleRenderAsRead
}