chore: enable noUncheckedIndexedAccess, better type check (#2608)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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),
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user