diff --git a/package-lock.json b/package-lock.json index 169b190..4db8c59 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lx-music-mobile", - "version": "1.2.0-beta.8", + "version": "1.2.0-beta.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "lx-music-mobile", - "version": "1.2.0-beta.8", + "version": "1.2.0-beta.9", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -40,14 +40,14 @@ "@react-native/metro-config": "^0.73.2", "@react-native/typescript-config": "^0.74.0", "@tsconfig/react-native": "^3.0.2", - "@types/react": "^18.2.42", + "@types/react": "^18.2.43", "@types/react-native": "^0.70.19", "@types/react-native-background-timer": "^2.0.2", "@types/react-native-vector-icons": "^6.4.18", "babel-plugin-module-resolver": "^5.0.0", "changelog-parser": "^3.0.1", "eslint-config-standard": "^17.1.0", - "eslint-config-standard-with-typescript": "^40.0.0", + "eslint-config-standard-with-typescript": "^42.0.0", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "typescript": "^5.3.3" @@ -3334,9 +3334,9 @@ "license": "MIT" }, "node_modules/@types/react": { - "version": "18.2.42", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.42.tgz", - "integrity": "sha512-c1zEr96MjakLYus/wPnuWDo1/zErfdU9rNsIGmE+NV71nx88FG9Ttgo5dqorXTu/LImX2f63WBP986gJkMPNbA==", + "version": "18.2.43", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.43.tgz", + "integrity": "sha512-nvOV01ZdBdd/KW6FahSbcNplt2jCJfyWdTos61RYHV+FVv5L/g9AOX1bmbVcWcLFL8+KHQfh1zVIQrud6ihyQA==", "dev": true, "dependencies": { "@types/prop-types": "*", @@ -5234,9 +5234,9 @@ } }, "node_modules/eslint-config-standard-with-typescript": { - "version": "40.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-40.0.0.tgz", - "integrity": "sha512-GXUJcwIXiTQaS3H4etv8a1lejVVdZYaxZNz3g7vt6GoJosQqMTurbmSC4FVGyHiGT/d1TjFr3+47A3xsHhsG+Q==", + "version": "42.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-42.0.0.tgz", + "integrity": "sha512-m1/2g/Sicun1uFZOFigJVeOqo9fE7OkMsNtilcpHwdCdcGr21qsGqYiyxYSvvHfJwY7w5OTQH0hxk8sM2N5Ohg==", "dev": true, "dependencies": { "@typescript-eslint/parser": "^6.4.0", @@ -13007,9 +13007,9 @@ "dev": true }, "@types/react": { - "version": "18.2.42", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.42.tgz", - "integrity": "sha512-c1zEr96MjakLYus/wPnuWDo1/zErfdU9rNsIGmE+NV71nx88FG9Ttgo5dqorXTu/LImX2f63WBP986gJkMPNbA==", + "version": "18.2.43", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.43.tgz", + "integrity": "sha512-nvOV01ZdBdd/KW6FahSbcNplt2jCJfyWdTos61RYHV+FVv5L/g9AOX1bmbVcWcLFL8+KHQfh1zVIQrud6ihyQA==", "dev": true, "requires": { "@types/prop-types": "*", @@ -14446,9 +14446,9 @@ "requires": {} }, "eslint-config-standard-with-typescript": { - "version": "40.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-40.0.0.tgz", - "integrity": "sha512-GXUJcwIXiTQaS3H4etv8a1lejVVdZYaxZNz3g7vt6GoJosQqMTurbmSC4FVGyHiGT/d1TjFr3+47A3xsHhsG+Q==", + "version": "42.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-42.0.0.tgz", + "integrity": "sha512-m1/2g/Sicun1uFZOFigJVeOqo9fE7OkMsNtilcpHwdCdcGr21qsGqYiyxYSvvHfJwY7w5OTQH0hxk8sM2N5Ohg==", "dev": true, "requires": { "@typescript-eslint/parser": "^6.4.0", diff --git a/package.json b/package.json index 3f23eaf..d6464a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lx-music-mobile", - "version": "1.2.0-beta.8", + "version": "1.2.0-beta.9", "versionCode": 62, "private": true, "scripts": { @@ -74,14 +74,14 @@ "@react-native/metro-config": "^0.73.2", "@react-native/typescript-config": "^0.74.0", "@tsconfig/react-native": "^3.0.2", - "@types/react": "^18.2.42", + "@types/react": "^18.2.43", "@types/react-native": "^0.70.19", "@types/react-native-background-timer": "^2.0.2", "@types/react-native-vector-icons": "^6.4.18", "babel-plugin-module-resolver": "^5.0.0", "changelog-parser": "^3.0.1", "eslint-config-standard": "^17.1.0", - "eslint-config-standard-with-typescript": "^40.0.0", + "eslint-config-standard-with-typescript": "^42.0.0", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "typescript": "^5.3.3" diff --git a/src/components/MusicAddModal/MusicAddModal.tsx b/src/components/MusicAddModal/MusicAddModal.tsx index f77f789..5591fd0 100644 --- a/src/components/MusicAddModal/MusicAddModal.tsx +++ b/src/components/MusicAddModal/MusicAddModal.tsx @@ -52,7 +52,7 @@ export default forwardRef(({ onAdded }, r dialogRef.current?.setVisible(false) if (selectInfo.isMove) { void moveListMusics(selectInfo.listId, listInfo.id, - [selectInfo.musicInfo as LX.Music.MusicInfo], + [selectInfo.musicInfo!], settingState.setting['list.addMusicLocationType'], ).then(() => { onAdded?.() @@ -62,7 +62,7 @@ export default forwardRef(({ onAdded }, r }) } else { void addListMusics(listInfo.id, - [selectInfo.musicInfo as LX.Music.MusicInfo], + [selectInfo.musicInfo!], settingState.setting['list.addMusicLocationType'], ).then(() => { onAdded?.() diff --git a/src/components/common/ChoosePath/List.tsx b/src/components/common/ChoosePath/List.tsx index b8bc2dd..c19ed58 100644 --- a/src/components/common/ChoosePath/List.tsx +++ b/src/components/common/ChoosePath/List.tsx @@ -17,7 +17,7 @@ const caches = new Map() const handleReadDir = async(path: string, dirOnly: boolean, filter?: RegExp, isRefresh = false) => { const cacheKey = `${path}_${dirOnly ? 'true' : 'false'}_${filter ? filter.toString() : 'null'}` - if (!isRefresh && caches.has(cacheKey)) return caches.get(cacheKey) as PathItem[] + if (!isRefresh && caches.has(cacheKey)) return caches.get(cacheKey)! return readDir(path).then(paths => { // console.log('read') // prevPath = path diff --git a/src/components/player/PlayerBar/components/Pic.tsx b/src/components/player/PlayerBar/components/Pic.tsx index 8fea1ff..6745e9f 100644 --- a/src/components/player/PlayerBar/components/Pic.tsx +++ b/src/components/player/PlayerBar/components/Pic.tsx @@ -44,7 +44,7 @@ export default ({ isHome }: { isHome: boolean }) => { // console.log('') // console.log(playMusicInfo) if (!musicInfo.id) return - navigations.pushPlayDetailScreen(commonState.componentIds.home as string) + navigations.pushPlayDetailScreen(commonState.componentIds.home!) // toast(global.i18n.t('play_detail_todo_tip'), 'long') } diff --git a/src/components/player/PlayerBar/components/Title.tsx b/src/components/player/PlayerBar/components/Title.tsx index ec4857b..bb6b4d4 100644 --- a/src/components/player/PlayerBar/components/Title.tsx +++ b/src/components/player/PlayerBar/components/Title.tsx @@ -21,7 +21,7 @@ export default ({ isHome }: { isHome: boolean }) => { // console.log('') // console.log(playMusicInfo) if (!musicInfo.id) return - navigations.pushPlayDetailScreen(commonState.componentIds.home as string) + navigations.pushPlayDetailScreen(commonState.componentIds.home!) // toast(global.i18n.t('play_detail_todo_tip'), 'long') } diff --git a/src/config/migrate.ts b/src/config/migrate.ts index f3de9fa..b9eb663 100644 --- a/src/config/migrate.ts +++ b/src/config/migrate.ts @@ -151,7 +151,7 @@ const timeStr2Intv = (timeStr: string) => { let intv = 0 let unit = 1 while (intvArr.length) { - intv += parseInt(intvArr.pop() as string) * unit + intv += parseInt(intvArr.pop()!) * unit unit *= 60 } return intv @@ -160,7 +160,7 @@ const migratePlayInfo = async() => { const playInfo = await getData(storageDataPrefixOld.playInfo) if (playInfo == null) return if (playInfo.list !== undefined) delete playInfo.list - if (playInfo.maxTime) playInfo.maxTime = timeStr2Intv(playInfo.maxTime) + if (playInfo.maxTime) playInfo.maxTime = timeStr2Intv(playInfo.maxTime as string) await saveData(storageDataPrefix.playInfo, playInfo) } /** diff --git a/src/config/migrateSetting.ts b/src/config/migrateSetting.ts index a1176d7..7d1a642 100644 --- a/src/config/migrateSetting.ts +++ b/src/config/migrateSetting.ts @@ -4,7 +4,7 @@ export default (setting: any): Partial => { setting = { ...setting } // 迁移 v1 之前的配置 - if (compareVer(setting.version, '2.0') < 0) { + if (compareVer(setting.version as string, '2.0') < 0) { setting['player.startupAutoPlay'] = setting.startupAutoPlay setting['player.togglePlayMethod'] = setting.player?.togglePlayMethod setting['player.isPlayHighQuality'] = setting.player?.highQuality diff --git a/src/core/hotSearch.ts b/src/core/hotSearch.ts index aa6732e..c1b7cb8 100644 --- a/src/core/hotSearch.ts +++ b/src/core/hotSearch.ts @@ -9,7 +9,7 @@ export const getList = async(source: Source): Promise => { if (source == 'all') continue task.push( hotSearchState.sourceList[source]?.length - ? Promise.resolve({ source, list: hotSearchState.sourceList[source] as Lists[number]['list'] }) + ? Promise.resolve({ source, list: hotSearchState.sourceList[source]! }) : ((musicSdk[source]?.hotSearch.getList() as Promise) ?? Promise.reject(new Error('source not found: ' + source))).catch((err: any) => { console.log(err) return { source, list: [] } @@ -20,7 +20,7 @@ export const getList = async(source: Source): Promise => { return hotSearchActions.setList(source, results) }) } else { - if (hotSearchState.sourceList[source]?.length) return hotSearchState.sourceList[source] as string[] + if (hotSearchState.sourceList[source]?.length) return hotSearchState.sourceList[source]! if (!musicSdk[source]?.hotSearch) { hotSearchActions.setList(source, []) return [] @@ -28,6 +28,7 @@ export const getList = async(source: Source): Promise => { return musicSdk[source]?.hotSearch.getList().catch((err: any) => { console.log(err) return { source, list: [] } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument }).then(data => hotSearchActions.setList(source, data.list)) } } diff --git a/src/core/init/player/playProgress.ts b/src/core/init/player/playProgress.ts index 0d7c5bc..67118ff 100644 --- a/src/core/init/player/playProgress.ts +++ b/src/core/init/player/playProgress.ts @@ -14,7 +14,7 @@ const delaySavePlayInfo = throttleBackgroundTimer(() => { void savePlayInfo({ time: playerState.progress.nowPlayTime, maxTime: playerState.progress.maxPlayTime, - listId: playerState.playMusicInfo.listId as string, + listId: playerState.playMusicInfo.listId!, index: playerState.playInfo.playIndex, }) }, 2000) @@ -121,7 +121,7 @@ export default () => { void savePlayInfo({ time: playerState.progress.nowPlayTime, maxTime: playerState.progress.maxPlayTime, - listId: playerState.playMusicInfo.listId as string, + listId: playerState.playMusicInfo.listId!, index: playerState.playInfo.playIndex, }) } diff --git a/src/core/init/syncSetting.ts b/src/core/init/syncSetting.ts index cd3b39f..1520088 100644 --- a/src/core/init/syncSetting.ts +++ b/src/core/init/syncSetting.ts @@ -10,9 +10,11 @@ const handleUpdateSourceNmaes = () => { kg: 'kg', mg: 'mg', wy: 'wy', + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument all: global.i18n.t(prefix + 'all' as any), } for (const { id } of musicSdk.sources) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument sourceNames[id as LX.OnlineSource] = global.i18n.t(prefix + id as any) } commonActions.setSourceNames(sourceNames) diff --git a/src/core/init/userApi/index.ts b/src/core/init/userApi/index.ts index 52e7947..814331f 100644 --- a/src/core/init/userApi/index.ts +++ b/src/core/init/userApi/index.ts @@ -71,7 +71,7 @@ export default async(setting: LX.AppSetting) => { // eslint-disable-next-line @typescript-eslint/promise-function-async }).then(res => { // console.log(res) - if (!/^https?:/.test(res.data.url)) return Promise.reject(new Error('Get url failed')) + if (!/^https?:/.test(res.data.url as string)) return Promise.reject(new Error('Get url failed')) return { type, url: res.data.url } }).catch(async err => { console.log(err.message) diff --git a/src/core/leaderboard.ts b/src/core/leaderboard.ts index de31395..2dda0b4 100644 --- a/src/core/leaderboard.ts +++ b/src/core/leaderboard.ts @@ -52,8 +52,8 @@ const getListLimit = async(source: LX.OnlineSource, bangId: string, page: number const prevPageKey = `${source}__${bangId}__${page - 1}` const tempListKey = `${source}__${bangId}__temp` - let listCache = cache.get(listKey) as CacheValue - if (!listCache) cache.set(listKey, listCache = new Map()) + let listCache = cache.get(listKey)! + if (!listCache) cache.set(listKey, listCache = new Map()) let sourcePage = 0 { const prevPageData = listCache.get(prevPageKey) as PageCache @@ -113,7 +113,7 @@ export const getListDetail = async(id: string, page: number, isRefresh = false): let listCache = cache.get(listKey) if (!listCache || isRefresh) { - cache.set(listKey, listCache = new Map()) + cache.set(listKey, listCache = new Map()) } let pageCache = listCache.get(pageKey) as PageCache @@ -132,9 +132,9 @@ export const getListDetailAll = async(id: string, isRefresh = false): Promise()) } const loadData = async(page: number): Promise => { diff --git a/src/core/music/utils.ts b/src/core/music/utils.ts index cf63b83..a3301e4 100644 --- a/src/core/music/utils.ts +++ b/src/core/music/utils.ts @@ -167,7 +167,7 @@ export const getOnlineOtherSourceMusicUrl = async({ musicInfos, quality, onToggl let musicInfo: LX.Music.MusicInfoOnline | null = null let itemQuality: LX.Quality | null = null // eslint-disable-next-line no-cond-assign - while (musicInfo = (musicInfos.shift() as LX.Music.MusicInfoOnline)) { + while (musicInfo = (musicInfos.shift()!)) { if (retryedSource.includes(musicInfo.source)) continue retryedSource.push(musicInfo.source) if (!assertApiSupport(musicInfo.source)) continue @@ -261,7 +261,7 @@ export const getOnlineOtherSourcePicUrl = async({ musicInfos, onToggleSource, is }> => { let musicInfo: LX.Music.MusicInfoOnline | null = null // eslint-disable-next-line no-cond-assign - while (musicInfo = (musicInfos.shift() as LX.Music.MusicInfoOnline)) { + while (musicInfo = (musicInfos.shift()!)) { if (retryedSource.includes(musicInfo.source)) continue retryedSource.push(musicInfo.source) // if (!assertApiSupport(musicInfo.source)) continue @@ -344,7 +344,7 @@ export const getOnlineOtherSourceLyricInfo = async({ musicInfos, onToggleSource, }> => { let musicInfo: LX.Music.MusicInfoOnline | null = null // eslint-disable-next-line no-cond-assign - while (musicInfo = (musicInfos.shift() as LX.Music.MusicInfoOnline)) { + while (musicInfo = (musicInfos.shift()!)) { if (retryedSource.includes(musicInfo.source)) continue retryedSource.push(musicInfo.source) // if (!assertApiSupport(musicInfo.source)) continue diff --git a/src/core/player/player.ts b/src/core/player/player.ts index de78020..92451b7 100644 --- a/src/core/player/player.ts +++ b/src/core/player/player.ts @@ -128,7 +128,7 @@ export const setMusicUrl = (musicInfo: LX.Music.MusicInfo | LX.Download.ListItem setResource(musicInfo, url, playerState.progress.nowPlayTime) }).catch((err: any) => { console.log(err) - setStatusText(err.message) + setStatusText(err.message as string) global.app_event.error() addDelayNextTimeout() }).finally(() => { diff --git a/src/core/player/timeoutExit.ts b/src/core/player/timeoutExit.ts index 4206b95..6d519bd 100644 --- a/src/core/player/timeoutExit.ts +++ b/src/core/player/timeoutExit.ts @@ -32,7 +32,7 @@ const timeoutTools = { clearTimeout() { if (!this.bgTimeout) return BackgroundTimer.clearTimeout(this.bgTimeout) - clearInterval(this.timeout as NodeJS.Timer) + clearInterval(this.timeout!) this.bgTimeout = null this.timeout = null this.time = -1 diff --git a/src/core/search/music.ts b/src/core/search/music.ts index af49918..02e78e7 100644 --- a/src/core/search/music.ts +++ b/src/core/search/music.ts @@ -1,4 +1,4 @@ -import searchMusicState, { type ListInfo, type Source } from '@/store/search/music/state' +import searchMusicState, { type Source } from '@/store/search/music/state' import searchMusicActions, { type SearchResult } from '@/store/search/music/action' import musicSdk from '@/utils/musicSdk' @@ -18,7 +18,7 @@ export const clearListInfo: typeof searchMusicActions.clearListInfo = (source) = export const search = async(text: string, page: number, sourceId: Source): Promise => { - const listInfo = searchMusicState.listInfos[sourceId] as ListInfo + const listInfo = searchMusicState.listInfos[sourceId]! if (!text) return [] const key = `${page}__${text}` if (sourceId == 'all') { diff --git a/src/core/search/songlist.ts b/src/core/search/songlist.ts index ab3af40..ea66df6 100644 --- a/src/core/search/songlist.ts +++ b/src/core/search/songlist.ts @@ -1,4 +1,4 @@ -import searchSonglistState, { type SearchListInfo, type Source, type ListInfoItem } from '@/store/search/songlist/state' +import searchSonglistState, { type Source, type ListInfoItem } from '@/store/search/songlist/state' import searchSonglistActions, { type SearchResult } from '@/store/search/songlist/action' import musicSdk from '@/utils/musicSdk' @@ -18,7 +18,7 @@ export const clearListInfo: typeof searchSonglistActions.clearListInfo = (source export const search = async(text: string, page: number, sourceId: Source): Promise => { - const listInfo = searchSonglistState.listInfos[sourceId] as SearchListInfo + const listInfo = searchSonglistState.listInfos[sourceId]! // if (!text) return [] const key = `${page}__${sourceId}__${text}` if (listInfo.key == key && listInfo.list.length) return listInfo.list @@ -26,7 +26,7 @@ export const search = async(text: string, page: number, sourceId: Source): Promi listInfo.key = key let task = [] for (const source of searchSonglistState.sources) { - if (source == 'all' || (page > 1 && page > (searchSonglistState.maxPages[source] as number))) continue + if (source == 'all' || (page > 1 && page > (searchSonglistState.maxPages[source]!))) continue task.push(((musicSdk[source]?.songList.search(text, page, searchSonglistState.listInfos.all.limit) as Promise) ?? Promise.reject(new Error('source not found: ' + source))).catch((error: any) => { console.log(error) return { diff --git a/src/core/songlist.ts b/src/core/songlist.ts index e285073..4a605fd 100644 --- a/src/core/songlist.ts +++ b/src/core/songlist.ts @@ -1,4 +1,4 @@ -import songlistState, { type TagInfo, type ListDetailInfo, type ListInfo, type SortInfo, type ListInfoItem } from '@/store/songlist/state' +import songlistState, { type TagInfo, type ListDetailInfo, type ListInfo, type ListInfoItem } from '@/store/songlist/state' import songlistActions from '@/store/songlist/action' import { deduplicationList, toNewMusicInfo } from '@/utils' import musicSdk from '@/utils/musicSdk' @@ -28,7 +28,7 @@ export const setSelectListInfo = (info: ListInfoItem) => { * @returns */ export const getSortList = (source: LX.OnlineSource) => { - return songlistState.sortList[source] as SortInfo[] + return songlistState.sortList[source]! } /** diff --git a/src/core/userApi.ts b/src/core/userApi.ts index fddd7ee..ef2ed3b 100644 --- a/src/core/userApi.ts +++ b/src/core/userApi.ts @@ -44,24 +44,31 @@ export const setUserApiAllowShowUpdateAlert = async(id: string, enable: boolean) export const log = { r_info(...params: any[]) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument writeLog.info(...params) }, r_warn(...params: any[]) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument writeLog.warn(...params) }, r_error(...params: any[]) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument writeLog.error(...params) }, log(...params: any[]) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument if (global.lx.isEnableUserApiLog) writeLog.info(...params) }, info(...params: any[]) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument if (global.lx.isEnableUserApiLog) writeLog.info(...params) }, warn(...params: any[]) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument if (global.lx.isEnableUserApiLog) writeLog.warn(...params) }, error(...params: any[]) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument if (global.lx.isEnableUserApiLog) writeLog.error(...params) }, } diff --git a/src/event/Event.ts b/src/event/Event.ts index 85abbdc..e1cadd9 100644 --- a/src/event/Event.ts +++ b/src/event/Event.ts @@ -26,6 +26,7 @@ export default class Event { let targetListeners = this.listeners.get(eventName) if (!targetListeners) return for (const listener of targetListeners) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument listener(...args) } }) diff --git a/src/plugins/player/hook.ts b/src/plugins/player/hook.ts index 9088b13..736d5fa 100644 --- a/src/plugins/player/hook.ts +++ b/src/plugins/player/hook.ts @@ -14,7 +14,7 @@ export const usePlaybackState = () => { void setPlayerState() const sub = TrackPlayer.addEventListener(Event.PlaybackState, data => { - setState(data.state) + setState(data.state as State) }) return () => { sub.remove() } @@ -99,6 +99,7 @@ export function useProgress(updateInterval: number) { } useEffect(() => { + // @ts-expect-error if (!pollTrackPlayerStates.includes(playerState)) return void getProgress() diff --git a/src/plugins/player/playList.ts b/src/plugins/player/playList.ts index e5e553f..a174afa 100644 --- a/src/plugins/player/playList.ts +++ b/src/plugins/player/playList.ts @@ -137,7 +137,7 @@ const handlePlayMusic = async(musicInfo: LX.Player.PlayMusic, url: string, time: await TrackPlayer.skip(queue.findIndex(t => t.id == track.id)) if (currentTrackIndex == null) { - if (!isTempTrack(track.id)) { + if (!isTempTrack(track.id as string)) { if (time) await TrackPlayer.seekTo(time) if (global.lx.restorePlayInfo) { await TrackPlayer.pause() @@ -152,7 +152,7 @@ const handlePlayMusic = async(musicInfo: LX.Player.PlayMusic, url: string, time: } } else { await TrackPlayer.pause() - if (!isTempTrack(track.id)) { + if (!isTempTrack(track.id as string)) { await TrackPlayer.seekTo(time) await TrackPlayer.play() } diff --git a/src/plugins/player/service.ts b/src/plugins/player/service.ts index 4bcdd29..91b2502 100644 --- a/src/plugins/player/service.ts +++ b/src/plugins/player/service.ts @@ -73,7 +73,7 @@ const registerPlaybackService = async() => { }) TrackPlayer.addEventListener(TPEvent.RemoteSeek, async({ position }) => { - global.app_event.setProgress(position) + global.app_event.setProgress(position as number) }) TrackPlayer.addEventListener(TPEvent.PlaybackState, async info => { diff --git a/src/plugins/player/utils.ts b/src/plugins/player/utils.ts index 1263d28..cb6661a 100644 --- a/src/plugins/player/utils.ts +++ b/src/plugins/player/utils.ts @@ -133,7 +133,7 @@ const playMusic = ((fn: (musicInfo: LX.Player.PlayMusic, url: string, time: numb _url = '' _time = 0 isDelayRun = false - fn(musicInfo as LX.Player.PlayMusic, url, time) + fn(musicInfo!, url, time) }, delay) } else { isDelayRun = true diff --git a/src/plugins/storage.ts b/src/plugins/storage.ts index 6146ce3..745e4d7 100644 --- a/src/plugins/storage.ts +++ b/src/plugins/storage.ts @@ -117,6 +117,7 @@ export const getDataMultiple = async(keys: T) => { if (value && partKeyPrefixRxp.test(value)) { promises.push(handleGetData(value)) } else { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument promises.push(Promise.resolve(value ? JSON.parse(value) : value)) } } diff --git a/src/plugins/sync/client/index.ts b/src/plugins/sync/client/index.ts index eac0b66..3a876ac 100644 --- a/src/plugins/sync/client/index.ts +++ b/src/plugins/sync/client/index.ts @@ -59,7 +59,7 @@ const disconnectServer = async(isResetStatus = true) => handleDisconnect().then( } }).catch((err: any) => { log.error(`disconnect error: ${err.message as string}`) - sendSyncMessage(err.message) + sendSyncMessage(err.message as string) }) export { diff --git a/src/plugins/sync/log.ts b/src/plugins/sync/log.ts index d983070..02f842f 100644 --- a/src/plugins/sync/log.ts +++ b/src/plugins/sync/log.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ import { log as writeLog } from '@/utils/log' export default { diff --git a/src/screens/Comment/components/Header.tsx b/src/screens/Comment/components/Header.tsx index 31e24ef..5a18458 100644 --- a/src/screens/Comment/components/Header.tsx +++ b/src/screens/Comment/components/Header.tsx @@ -20,7 +20,7 @@ export default memo(({ musicInfo }: { const t = useI18n() const back = () => { - void pop(commonState.componentIds.comment as string) + void pop(commonState.componentIds.comment!) } return ( diff --git a/src/screens/Home/Views/Mylist/MyList/listAction.ts b/src/screens/Home/Views/Mylist/MyList/listAction.ts index b11505a..8799036 100644 --- a/src/screens/Home/Views/Mylist/MyList/listAction.ts +++ b/src/screens/Home/Views/Mylist/MyList/listAction.ts @@ -35,7 +35,7 @@ const readListData = async(path: string) => { listData = configData.data break default: - showImportTip(configData.type) + showImportTip(configData.type as string) return null } return listData diff --git a/src/screens/Home/Views/Search/MusicList.tsx b/src/screens/Home/Views/Search/MusicList.tsx index 027d36f..068c07d 100644 --- a/src/screens/Home/Views/Search/MusicList.tsx +++ b/src/screens/Home/Views/Search/MusicList.tsx @@ -1,7 +1,7 @@ import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react' import OnlineList, { type OnlineListType, type OnlineListProps } from '@/components/OnlineList' import { search } from '@/core/search/music' -import searchMusicState, { type ListInfo, type Source } from '@/store/search/music/state' +import searchMusicState, { type Source } from '@/store/search/music/state' // export type MusicListProps = Pick((props, ref) => { } const handleLoadMore: OnlineListProps['onLoadMore'] = () => { listRef.current?.setStatus('loading') - const info = searchMusicState.listInfos[searchInfoRef.current.source] as ListInfo + const info = searchMusicState.listInfos[searchInfoRef.current.source]! const page = info?.list.length ? info.page + 1 : 1 search(searchInfoRef.current.text, page, searchInfoRef.current.source).then((list) => { // const result = setListInfo(listDetail, searchMusicState.listDetailInfo.id, page) diff --git a/src/screens/Home/Views/Search/SonglistList.tsx b/src/screens/Home/Views/Search/SonglistList.tsx index 25cf177..f4daaff 100644 --- a/src/screens/Home/Views/Search/SonglistList.tsx +++ b/src/screens/Home/Views/Search/SonglistList.tsx @@ -2,7 +2,7 @@ import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react' import { search } from '@/core/search/songlist' import Songlist, { type SonglistProps, type SonglistType } from '@/screens/Home/Views/SongList/components/Songlist' -import searchSonglistState, { type SearchListInfo, type Source } from '@/store/search/songlist/state' +import searchSonglistState, { type Source } from '@/store/search/songlist/state' // export type MusicListProps = Pick((props, ref) => { } const handleLoadMore: SonglistProps['onLoadMore'] = () => { listRef.current?.setStatus('loading') - const info = searchSonglistState.listInfos[searchInfoRef.current.source] as SearchListInfo + const info = searchSonglistState.listInfos[searchInfoRef.current.source]! const page = info.list.length ? info.page + 1 : 1 search(searchInfoRef.current.text, page, searchInfoRef.current.source).then((list) => { // const result = setListInfo(listDetail, searchSonglistState.listDetailInfo.id, page) diff --git a/src/screens/Home/Views/Setting/settings/Backup/actions.ts b/src/screens/Home/Views/Setting/settings/Backup/actions.ts index 5f420e0..6c602b5 100644 --- a/src/screens/Home/Views/Setting/settings/Backup/actions.ts +++ b/src/screens/Home/Views/Setting/settings/Backup/actions.ts @@ -122,27 +122,34 @@ const importPlayList = async(path: string) => { await overwriteListMusics(LIST_IDS.DEFAULT, filterMusicList((configData.data as LX.List.MyDefaultListInfoFull).list.map(m => toNewMusicInfo(m)))) break case 'playList': + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument await importOldListData(configData.data) break case 'playList_v2': + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument await importNewListData(configData.data) break case 'allData': // 兼容0.6.2及以前版本的列表数据 if (configData.defaultList) await overwriteListMusics(LIST_IDS.DEFAULT, filterMusicList((configData.defaultList as LX.List.MyDefaultListInfoFull).list.map(m => toNewMusicInfo(m)))) + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument else await importOldListData(configData.playList) break case 'allData_v2': + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument await importNewListData(configData.playList) break case 'playListPart': configData.data.list = filterMusicList((configData.data as LX.ConfigFile.MyListInfoPart['data']).list.map(m => toNewMusicInfo(m))) + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument void handleImportListPart(configData.data) return true case 'playListPart_v2': configData.data.list = filterMusicList((configData.data as LX.ConfigFile.MyListInfoPart['data']).list).map(m => fixNewMusicInfoQuality(m)) + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument void handleImportListPart(configData.data) return true + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument default: showImportTip(configData.type) } } diff --git a/src/screens/Home/Views/SongList/HeaderBar/OpenList/index.tsx b/src/screens/Home/Views/SongList/HeaderBar/OpenList/index.tsx index 60bdf01..22bd862 100644 --- a/src/screens/Home/Views/SongList/HeaderBar/OpenList/index.tsx +++ b/src/screens/Home/Views/SongList/HeaderBar/OpenList/index.tsx @@ -41,7 +41,7 @@ export default forwardRef((props, ref) => { desc: undefined, source: songlistInfoRef.current.source, }) - navigations.pushSonglistDetailScreen(commonState.componentIds.home as string, id) + navigations.pushSonglistDetailScreen(commonState.componentIds.home!, id) } // const handleSourceChange: ModalProps['onSourceChange'] = (source) => { diff --git a/src/screens/Home/Views/SongList/HeaderBar/SortTab.tsx b/src/screens/Home/Views/SongList/HeaderBar/SortTab.tsx index d90bd24..57b3dd5 100644 --- a/src/screens/Home/Views/SongList/HeaderBar/SortTab.tsx +++ b/src/screens/Home/Views/SongList/HeaderBar/SortTab.tsx @@ -26,7 +26,7 @@ export default forwardRef(({ onSortChange }, ref) => useImperativeHandle(ref, () => ({ setSource(source, activeTab) { scrollViewRef.current?.scrollTo({ x: 0 }) - setSortList(songlistState.sortList[source] as SortInfo[]) + setSortList(songlistState.sortList[source]!) setActiveId(activeTab) }, })) diff --git a/src/screens/Home/Views/SongList/components/Songlist/index.tsx b/src/screens/Home/Views/SongList/components/Songlist/index.tsx index cd153ba..1403683 100644 --- a/src/screens/Home/Views/SongList/components/Songlist/index.tsx +++ b/src/screens/Home/Views/SongList/components/Songlist/index.tsx @@ -34,7 +34,7 @@ export default forwardRef(({ const handleOpenDetail = (item: ListInfoItem, index: number) => { // console.log(item) setSelectListInfo(item) - navigations.pushSonglistDetailScreen(commonState.componentIds.home as string, item.id) + navigations.pushSonglistDetailScreen(commonState.componentIds.home!, item.id) } return ( diff --git a/src/screens/PlayDetail/Horizontal/MoreBtn/MusicAddBtn.tsx b/src/screens/PlayDetail/Horizontal/MoreBtn/MusicAddBtn.tsx index 9e3c920..f58d4f0 100644 --- a/src/screens/PlayDetail/Horizontal/MoreBtn/MusicAddBtn.tsx +++ b/src/screens/PlayDetail/Horizontal/MoreBtn/MusicAddBtn.tsx @@ -13,7 +13,7 @@ export default () => { musicAddModalRef.current?.show({ musicInfo: 'progress' in musicInfo ? musicInfo.metadata.musicInfo : musicInfo, isMove: false, - listId: playerState.playMusicInfo.listId as string, + listId: playerState.playMusicInfo.listId!, }) } diff --git a/src/screens/PlayDetail/Horizontal/components/CommentBtn.tsx b/src/screens/PlayDetail/Horizontal/components/CommentBtn.tsx index e800102..e941a25 100644 --- a/src/screens/PlayDetail/Horizontal/components/CommentBtn.tsx +++ b/src/screens/PlayDetail/Horizontal/components/CommentBtn.tsx @@ -5,7 +5,7 @@ import commonState from '@/store/common/state' export default () => { const handleShowCommentScreen = () => { - navigations.pushCommentScreen(commonState.componentIds.playDetail as string) + navigations.pushCommentScreen(commonState.componentIds.playDetail!) } return diff --git a/src/screens/PlayDetail/Horizontal/components/Header.tsx b/src/screens/PlayDetail/Horizontal/components/Header.tsx index aeb0821..8a15877 100644 --- a/src/screens/PlayDetail/Horizontal/components/Header.tsx +++ b/src/screens/PlayDetail/Horizontal/components/Header.tsx @@ -33,7 +33,7 @@ export default memo(() => { const popupRef = useRef(null) const back = () => { - void pop(commonState.componentIds.playDetail as string) + void pop(commonState.componentIds.playDetail!) } const showSetting = () => { popupRef.current?.show() diff --git a/src/screens/PlayDetail/Vertical/Player/components/MoreBtn/CommentBtn.tsx b/src/screens/PlayDetail/Vertical/Player/components/MoreBtn/CommentBtn.tsx index e800102..e941a25 100644 --- a/src/screens/PlayDetail/Vertical/Player/components/MoreBtn/CommentBtn.tsx +++ b/src/screens/PlayDetail/Vertical/Player/components/MoreBtn/CommentBtn.tsx @@ -5,7 +5,7 @@ import commonState from '@/store/common/state' export default () => { const handleShowCommentScreen = () => { - navigations.pushCommentScreen(commonState.componentIds.playDetail as string) + navigations.pushCommentScreen(commonState.componentIds.playDetail!) } return diff --git a/src/screens/PlayDetail/Vertical/Player/components/MoreBtn/MusicAddBtn.tsx b/src/screens/PlayDetail/Vertical/Player/components/MoreBtn/MusicAddBtn.tsx index 9e3c920..f58d4f0 100644 --- a/src/screens/PlayDetail/Vertical/Player/components/MoreBtn/MusicAddBtn.tsx +++ b/src/screens/PlayDetail/Vertical/Player/components/MoreBtn/MusicAddBtn.tsx @@ -13,7 +13,7 @@ export default () => { musicAddModalRef.current?.show({ musicInfo: 'progress' in musicInfo ? musicInfo.metadata.musicInfo : musicInfo, isMove: false, - listId: playerState.playMusicInfo.listId as string, + listId: playerState.playMusicInfo.listId!, }) } diff --git a/src/screens/PlayDetail/Vertical/components/Header.tsx b/src/screens/PlayDetail/Vertical/components/Header.tsx index 942708a..799ddaa 100644 --- a/src/screens/PlayDetail/Vertical/components/Header.tsx +++ b/src/screens/PlayDetail/Vertical/components/Header.tsx @@ -33,7 +33,7 @@ export default memo(() => { const popupRef = useRef(null) const back = () => { - void pop(commonState.componentIds.playDetail as string) + void pop(commonState.componentIds.playDetail!) } const showSetting = () => { popupRef.current?.show() diff --git a/src/screens/SonglistDetail/ActionBar.tsx b/src/screens/SonglistDetail/ActionBar.tsx index c63fcd3..99a3e60 100644 --- a/src/screens/SonglistDetail/ActionBar.tsx +++ b/src/screens/SonglistDetail/ActionBar.tsx @@ -17,7 +17,7 @@ export default memo(() => { const t = useI18n() const back = () => { - void pop(commonState.componentIds.songlistDetail as string) + void pop(commonState.componentIds.songlistDetail!) } const handlePlayAll = () => { diff --git a/src/store/search/music/action.ts b/src/store/search/music/action.ts index 6e2f858..620415d 100644 --- a/src/store/search/music/action.ts +++ b/src/store/search/music/action.ts @@ -1,4 +1,4 @@ -import state, { type InitState, type ListInfo, type Source } from './state' +import state, { type InitState, type Source } from './state' import { sortInsert, similar, arrPush } from '@/utils/common' import { deduplicationList, toNewMusicInfo } from '@/utils' @@ -21,6 +21,7 @@ export interface SearchResult { const handleSortList = (list: LX.Music.MusicInfoOnline[], keyword: string) => { let arr: any[] = [] for (const item of list) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument sortInsert(arr, { num: similar(keyword, `${item.name} ${item.singer}`), data: item, @@ -59,7 +60,7 @@ const setLists = (results: SearchResult[], page: number, text: string): LX.Music const setList = (datas: SearchResult, page: number, text: string): LX.Music.MusicInfoOnline[] => { // console.log(datas.source, datas.list) - let listInfo = state.listInfos[datas.source] as ListInfo + let listInfo = state.listInfos[datas.source]! const list = datas.list.map(s => toNewMusicInfo(s) as LX.Music.MusicInfoOnline) listInfo.list = deduplicationList(page == 1 ? list : [...listInfo.list, ...list]) if (page == 1 || (datas.total && datas.list.length)) listInfo.total = datas.total @@ -87,7 +88,7 @@ export default { } }, clearListInfo(sourceId: Source) { - let listInfo = state.listInfos[sourceId] as ListInfo + let listInfo = state.listInfos[sourceId]! listInfo.list = [] listInfo.page = 0 listInfo.maxPage = 0 diff --git a/src/store/search/songlist/action.ts b/src/store/search/songlist/action.ts index bcdf20f..28238ff 100644 --- a/src/store/search/songlist/action.ts +++ b/src/store/search/songlist/action.ts @@ -1,6 +1,6 @@ import { sortInsert, similar } from '@/utils/common' -import type { InitState, ListInfoItem, SearchListInfo, Source } from './state' +import type { InitState, ListInfoItem, Source } from './state' import state from './state' export interface SearchResult { @@ -20,6 +20,7 @@ export interface SearchResult { const handleSortList = (list: ListInfoItem[], keyword: string) => { let arr: any[] = [] for (const item of list) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument sortInsert(arr, { num: similar(keyword, item.name), data: item, @@ -57,7 +58,7 @@ const setLists = (results: SearchResult[], page: number, text: string): ListInfo const setList = (datas: SearchResult, page: number, text: string): ListInfoItem[] => { // console.log(datas.source, datas.list) - let listInfo = state.listInfos[datas.source] as SearchListInfo + let listInfo = state.listInfos[datas.source]! listInfo.list = page == 1 ? datas.list : [...listInfo.list, ...datas.list] if (page == 1 || (datas.total && datas.list.length)) listInfo.total = datas.total else listInfo.total = datas.limit * page @@ -83,7 +84,7 @@ export default { } }, clearListInfo(sourceId: Source) { - let listInfo = state.listInfos[sourceId] as SearchListInfo + let listInfo = state.listInfos[sourceId]! listInfo.page = 1 listInfo.limit = 20 listInfo.total = 0 diff --git a/src/utils/common.ts b/src/utils/common.ts index de42346..220684a 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -21,7 +21,7 @@ export const sizeFormate = (size: number): string => { * @param date 时间 * @returns 时间对象或空字符串 */ -export const toDateObj = (date: any): Date | '' => { +export const toDateObj = (date?: number | string | Date): Date | '' => { // console.log(date) if (!date) return '' switch (typeof date) { @@ -44,7 +44,7 @@ const numFix = (n: number): string => n < 10 ? (`0${n}`) : n.toString() * @param _date 时间 * @param format Y-M-D h:m:s Y年 M月 D日 h时 m分 s秒 */ -export const dateFormat = (_date: any, format = 'Y-M-D h:m:s') => { +export const dateFormat = (_date: number | string | Date, format = 'Y-M-D h:m:s') => { // console.log(date) const date = toDateObj(_date) if (!date) return '' diff --git a/src/utils/index.ts b/src/utils/index.ts index 10729be..a6d0a38 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -33,7 +33,7 @@ export const toNewMusicInfo = (oldMusicInfo: any): LX.Music.MusicInfo => { if (oldMusicInfo.source == 'local') { meta.filePath = oldMusicInfo.filePath ?? oldMusicInfo.songmid ?? '' - meta.ext = oldMusicInfo.ext ?? /\.(\w+)$/.exec(meta.filePath)?.[1] ?? '' + meta.ext = oldMusicInfo.ext ?? /\.(\w+)$/.exec(meta.filePath as string)?.[1] ?? '' } else { meta.qualitys = oldMusicInfo.types meta._qualitys = oldMusicInfo._types diff --git a/src/utils/listManage.ts b/src/utils/listManage.ts index 4425d29..22ae971 100644 --- a/src/utils/listManage.ts +++ b/src/utils/listManage.ts @@ -186,7 +186,7 @@ export const userListsUpdatePosition = (position: number, ids: string[]) => { const map = new Map() for (const item of newUserLists) map.set(item.id, item) for (const id of ids) { - const listInfo = map.get(id) as LX.List.UserListInfo + const listInfo = map.get(id)! listInfo.locationUpdateTime = Date.now() updateLists.push(listInfo) map.delete(id) @@ -207,7 +207,7 @@ export const getListMusicSync = (id: string | null) => { */ export const getListMusics = async(listId: string): Promise => { if (!listId) return [] - if (allMusicList.has(listId)) return allMusicList.get(listId) as LX.Music.MusicInfo[] + if (allMusicList.has(listId)) return allMusicList.get(listId)! const list = await getListMusicsFromStore(listId) return setMusicList(listId, list) } @@ -303,7 +303,7 @@ export const listMusicUpdatePosition = async(listId: string, position: number, i const map = new Map() for (const item of targetList) map.set(item.id, item) for (const id of ids) { - infos.push(map.get(id) as LX.Music.MusicInfo) + infos.push(map.get(id)!) map.delete(id) } const list = targetList.filter(mInfo => map.has(mInfo.id)) diff --git a/src/utils/nativeModules/lyricDesktop.ts b/src/utils/nativeModules/lyricDesktop.ts index d6c68f0..1063807 100644 --- a/src/utils/nativeModules/lyricDesktop.ts +++ b/src/utils/nativeModules/lyricDesktop.ts @@ -186,7 +186,7 @@ export const setAlpha = async(alpha: number): Promise => { * set text size * @param size text size */ -export const setTextSize = async(size: any): Promise => { +export const setTextSize = async(size: number): Promise => { if (!isShowLyric) return Promise.resolve() return LyricModule.setTextSize(getTextSize(size)) } @@ -234,10 +234,11 @@ export const openOverlayPermissionActivity = async(): Promise => { return LyricModule.openOverlayPermissionActivity() } -export const onPositionChange = (callback: (position: { x: number, y: number }) => void): () => void => { +export const onPositionChange = (handler: (position: { x: number, y: number }) => void): () => void => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const eventEmitter = new NativeEventEmitter(LyricModule) const eventListener = eventEmitter.addListener('set-position', event => { - callback(event) + handler(event as { x: number, y: number }) }) return () => { diff --git a/src/utils/nativeModules/userApi.ts b/src/utils/nativeModules/userApi.ts index 631a133..842162f 100644 --- a/src/utils/nativeModules/userApi.ts +++ b/src/utils/nativeModules/userApi.ts @@ -76,15 +76,16 @@ export interface Actions { } export type ActionsEvent = { [K in keyof Actions]: { action: K, data: Actions[K] } }[keyof Actions] -export const onScriptAction = (callback: (event: ActionsEvent) => void): () => void => { +export const onScriptAction = (handler: (event: ActionsEvent) => void): () => void => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const eventEmitter = new NativeEventEmitter(UserApiModule) const eventListener = eventEmitter.addListener('api-action', event => { - if (event.data) event.data = JSON.parse(event.data) + if (event.data) event.data = JSON.parse(event.data as string) if (event.action == 'init') { if (event.data.info) event.data.info = { ...loadScriptInfo, ...event.data.info } else event.data.info = { ...loadScriptInfo } } - callback(event) + handler(event as ActionsEvent) }) return () => { diff --git a/src/utils/nativeModules/utils.ts b/src/utils/nativeModules/utils.ts index e1d0c36..c4e877d 100644 --- a/src/utils/nativeModules/utils.ts +++ b/src/utils/nativeModules/utils.ts @@ -58,10 +58,11 @@ export const getSystemLocales = async(): Promise => { return UtilsModule.getSystemLocales() } -export const onScreenStateChange = (callback: (state: 'ON' | 'OFF') => void): () => void => { +export const onScreenStateChange = (handler: (state: 'ON' | 'OFF') => void): () => void => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const eventEmitter = new NativeEventEmitter(UtilsModule) const eventListener = eventEmitter.addListener('screen-state', event => { - callback(event.state) + handler(event.state as 'ON' | 'OFF') }) return () => { @@ -73,11 +74,12 @@ export const getWindowSize = async(): Promise<{ width: number, height: number }> return UtilsModule.getWindowSize() } -export const onWindowSizeChange = (callback: (size: { width: number, height: number }) => void): () => void => { +export const onWindowSizeChange = (handler: (size: { width: number, height: number }) => void): () => void => { UtilsModule.listenWindowSizeChanged() + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const eventEmitter = new NativeEventEmitter(UtilsModule) const eventListener = eventEmitter.addListener('screen-size-changed', event => { - callback(event) + handler(event as { width: number, height: number }) }) return () => { diff --git a/src/utils/tools.ts b/src/utils/tools.ts index 7a17573..71502d6 100644 --- a/src/utils/tools.ts +++ b/src/utils/tools.ts @@ -169,7 +169,7 @@ export const handleReadFile = async(path: string): Promise => { // 修复PC v1.14.0出现的导出数据被序列化两次的问题 if (typeof data != 'object') { try { - data = JSON.parse(data) + data = JSON.parse(data as string) } catch (err) { return data } @@ -509,6 +509,7 @@ export const createStyle = >(styles: T | Sty for (const [n, s] of Object.entries(newStyle)) { newStyle[n] = trasformeStyle(s) } + // @ts-expect-error return StyleSheet.create(newStyle as StyleSheet.NamedStyles) } diff --git a/tsconfig.json b/tsconfig.json index 4303291..cb87be2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { /* Visit https://aka.ms/tsconfig.json to read more about this file */ + "module": "ESNext", "types": ["react-native", "node"], /* Completeness */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */