添加setTimeout和clearTimeout支持

This commit is contained in:
fofolee
2025-02-20 21:57:53 +08:00
parent 60ac9fbc81
commit cf37411717
4 changed files with 28 additions and 7 deletions

View File

@@ -88,3 +88,6 @@ declare var console: {
log(message?: any): void,
error(message?: any): void
}
declare var setTimeout: (callback: () => void, ms: number) => number;
declare var clearTimeout: (timeoutId: number) => void;

View File

@@ -235,6 +235,19 @@ interface quickcommandApi {
*/
setTimeout(callback: () => void, ms);
/**
* 清除异步等待
*
* @param timeoutId 等待的timeoutId
* ```js
* const timeoutId = quickcommand.setTimeout(()=>{
* console.log('这条内容不会被打印')
* }, 2000)
* quickcommand.clearTimeout(timeoutId)
* ```
*/
clearTimeout(timeoutId: number): void;
/**
* async 等待
*