提交 1a9fc7a6 编写于 作者: fxy060608's avatar fxy060608

fix(types): setTimeout

上级 3a67ae3a
......@@ -198,7 +198,7 @@ const onAudioStateChange = ({
}
}, 200)
} else if (state === 'pause' || state === 'stop' || state === 'error') {
clearInterval(audio.__timing)
clearInterval(audio.__timing!)
}
}
}
......@@ -306,7 +306,7 @@ class InnerAudioContext implements UniApp.InnerAudioContext {
*
* @param __timing 当前Audio所使用的timer
*/
__timing?: number
__timing?: ReturnType<typeof setInterval>
_options: Data
constructor(id: string) {
this.id = id
......@@ -366,7 +366,7 @@ class InnerAudioContext implements UniApp.InnerAudioContext {
}
destroy() {
clearInterval(this.__timing)
clearInterval(this.__timing!)
if (audios[this.id]) {
audios[this.id].close()
delete audios[this.id]
......
......@@ -78,7 +78,7 @@ const callbacks: Record<eventNames, Function[]> = {
}
let audio: Audio
let timeUpdateTimer: number | null = null
let timeUpdateTimer: ReturnType<typeof setInterval> | null = null
const TIME_UPDATE = 250
const events: Events[] = ['play', 'pause', 'ended', 'stop', 'canplay']
......
......@@ -15,7 +15,7 @@ interface Recorder {
let recorder: PlusAudioAudioRecorder
let recording: boolean = false
let recordTimeout: number
let recordTimeout: ReturnType<typeof setTimeout>
const publishRecorderStateChange = (state: string, res = {}) => {
onRecorderStateChange(
......
......@@ -136,7 +136,7 @@ export const request = defineTaskApi<API_TYPE_REQUEST>(
const stream = requireNativePlugin('stream')
const headers: Headers = {}
let abortTimeout: number
let abortTimeout: ReturnType<typeof setTimeout>
let aborted: boolean
let hasContentType = false
......
......@@ -23,7 +23,7 @@ type ToastType = 'loading' | 'toast' | ''
let toast: PlusNativeUIWaitingObj | null
let isShowToast: boolean = false
let toastType: ToastType = ''
let timeout: number | null
let timeout: ReturnType<typeof setTimeout> | null
export const showLoading = defineAsyncApi<API_TYPE_SHOW_LOADING>(
API_SHOW_LOADING,
......
......@@ -17,6 +17,7 @@ const plugins = [
mainJs_1.uniMainJsPlugin(),
manifestJson_1.uniManifestJsonPlugin(),
pagesJson_1.uniPagesJsonPlugin(),
uni_cli_shared_1.uniViteInjectPlugin(uni_cli_shared_1.initProvide()),
plugin_1.UniAppPlugin,
];
if (!process.env.UNI_APP_CODE_SPLITING) {
......
......@@ -6,8 +6,8 @@ export interface CreateScrollListenerOptions {
export function disableScrollListener(evt: Event) {
evt.preventDefault()
}
let testReachBottomTimer: number
// 不直接声明为 number,可能跟 node.setTimeout 有冲突
let testReachBottomTimer: ReturnType<typeof setTimeout>
let lastScrollHeight = 0
export function createScrollListener({
onPageScroll,
......
......@@ -5,12 +5,12 @@ const LONGPRESS_THRESHOLD = 10
const passiveOptions = passive(true)
let longPressTimer = 0
let longPressTimer: ReturnType<typeof setTimeout> | null
function clearLongPressTimer() {
if (longPressTimer) {
clearTimeout(longPressTimer)
longPressTimer = 0
longPressTimer = null
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册