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
@@ -78,7 +78,7 @@ export default function createHTMLMediaHook<T extends HTMLAudioElement | HTMLVid
const getState = useEventCallback(() => state)
const ref = useRef<T | null>(null)
const wrapEvent = (userEvent, proxyEvent?) => (event) => {
const wrapEvent = (userEvent: any, proxyEvent?: any) => (event: any) => {
try {
proxyEvent && proxyEvent(event)
} finally {
+3 -3
View File
@@ -27,7 +27,7 @@ export function useLongPress({
events.onTouchStart?.(e)
e.preventDefault()
isLongPress.current = false
const touch = e.touches[0]
const touch = e.touches[0]!
clearTimeout(timerRef.current)
startPosition.current = {
@@ -61,7 +61,7 @@ export function useLongPress({
const compatEventProxy = new Proxy(compatEvent, {
get: (target, prop: string) => {
if (compatProperties.has(prop)) {
return target[prop]
return target[prop as keyof typeof target]
}
throw new Error(`Property ${prop} not implemented on compatEvent`)
},
@@ -75,7 +75,7 @@ export function useLongPress({
events.onTouchMove?.(e)
if (!startPosition.current) return
const touch = e.touches[0]
const touch = e.touches[0]!
const currentX = touch.clientX + window.scrollX
const currentY = touch.clientY + window.scrollY
+1 -1
View File
@@ -7,7 +7,7 @@ export const useSetState = <T extends object>(
initialState: T = {} as T,
): [T, (patch: Partial<T> | ((prevState: T) => Partial<T>)) => void] => {
const [state, set] = useState<T>(initialState)
const setState = useCallback((patch) => {
const setState = useCallback((patch: any) => {
set((prevState) =>
Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch),
)
+1 -1
View File
@@ -3,7 +3,7 @@ import { useEffect, useRef } from "react"
const titleTemplate = IN_ELECTRON ? `%s` : `%s | ${APP_NAME}`
export const useTitle = (title?: Nullable<string>) => {
export const useTitle = (title?: string | null) => {
const currentTitleRef = useRef(document.title)
useEffect(() => {
if (!title) return