index.d.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*! *****************************************************************************
  2. Copyright (c) 2022 Tencent, Inc. All rights reserved.
  3. Permission is hereby granted, free of charge, to any person obtaining a copy of
  4. this software and associated documentation files (the "Software"), to deal in
  5. the Software without restriction, including without limitation the rights to
  6. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  7. of the Software, and to permit persons to whom the Software is furnished to do
  8. so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.
  18. ***************************************************************************** */
  19. /// <reference path="./lib.wx.app.d.ts" />
  20. /// <reference path="./lib.wx.page.d.ts" />
  21. /// <reference path="./lib.wx.api.d.ts" />
  22. /// <reference path="./lib.wx.cloud.d.ts" />
  23. /// <reference path="./lib.wx.component.d.ts" />
  24. /// <reference path="./lib.wx.behavior.d.ts" />
  25. /// <reference path="./lib.wx.event.d.ts" />
  26. declare namespace WechatMiniprogram {
  27. type IAnyObject = Record<string, any>
  28. type Optional<F> = F extends (arg: infer P) => infer R ? (arg?: P) => R : F
  29. type OptionalInterface<T> = { [K in keyof T]: Optional<T[K]> }
  30. interface AsyncMethodOptionLike {
  31. success?: (...args: any[]) => void
  32. }
  33. type PromisifySuccessResult<
  34. P,
  35. T extends AsyncMethodOptionLike
  36. > = P extends {
  37. success: any
  38. }
  39. ? void
  40. : P extends { fail: any }
  41. ? void
  42. : P extends { complete: any }
  43. ? void
  44. : Promise<Parameters<Exclude<T['success'], undefined>>[0]>
  45. // TODO: Extract real definition from `lib.dom.d.ts` to replace this
  46. type IIRFilterNode = any
  47. type WaveShaperNode = any
  48. type ConstantSourceNode = any
  49. type OscillatorNode = any
  50. type GainNode = any
  51. type BiquadFilterNode = any
  52. type PeriodicWaveNode = any
  53. type BufferSourceNode = any
  54. type ChannelSplitterNode = any
  55. type ChannelMergerNode = any
  56. type DelayNode = any
  57. type DynamicsCompressorNode = any
  58. type ScriptProcessorNode = any
  59. type PannerNode = any
  60. type AudioListener = any
  61. type WebGLTexture = any
  62. type WebGLRenderingContext = any
  63. }
  64. declare let console: WechatMiniprogram.Console
  65. declare let wx: WechatMiniprogram.Wx
  66. /** 引入模块。返回模块通过 `module.exports` 或 `exports` 暴露的接口。 */
  67. declare function require(
  68. /** 需要引入模块文件相对于当前文件的相对路径,或 npm 模块名,或 npm 模块路径。不支持绝对路径 */
  69. module: string
  70. ): any
  71. /** 引入插件。返回插件通过 `main` 暴露的接口。 */
  72. declare function requirePlugin(
  73. /** 需要引入的插件的 alias */
  74. module: string
  75. ): any
  76. /** 插件引入当前使用者小程序。返回使用者小程序通过 [插件配置中 `export` 暴露的接口](https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/using.html#%E5%AF%BC%E5%87%BA%E5%88%B0%E6%8F%92%E4%BB%B6)。
  77. *
  78. * 该接口只在插件中存在
  79. *
  80. * 最低基础库: `2.11.1` */
  81. declare function requireMiniProgram(): any
  82. /** 当前模块对象 */
  83. declare let module: {
  84. /** 模块向外暴露的对象,使用 `require` 引用该模块时可以获取 */
  85. exports: any
  86. }
  87. /** `module.exports` 的引用 */
  88. declare let exports: any
  89. /** [clearInterval(number intervalID)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/clearInterval.html)
  90. *
  91. * 取消由 setInterval 设置的定时器。 */
  92. declare function clearInterval(
  93. /** 要取消的定时器的 ID */
  94. intervalID: number
  95. ): void
  96. /** [clearTimeout(number timeoutID)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/clearTimeout.html)
  97. *
  98. * 取消由 setTimeout 设置的定时器。 */
  99. declare function clearTimeout(
  100. /** 要取消的定时器的 ID */
  101. timeoutID: number
  102. ): void
  103. /** [number setInterval(function callback, number delay, any rest)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/setInterval.html)
  104. *
  105. * 设定一个定时器。按照指定的周期(以毫秒计)来执行注册的回调函数 */
  106. declare function setInterval(
  107. /** 回调函数 */
  108. callback: (...args: any[]) => any,
  109. /** 执行回调函数之间的时间间隔,单位 ms。 */
  110. delay?: number,
  111. /** param1, param2, ..., paramN 等附加参数,它们会作为参数传递给回调函数。 */
  112. rest?: any
  113. ): number
  114. /** [number setTimeout(function callback, number delay, any rest)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/setTimeout.html)
  115. *
  116. * 设定一个定时器。在定时到期以后执行注册的回调函数 */
  117. declare function setTimeout(
  118. /** 回调函数 */
  119. callback: (...args: any[]) => any,
  120. /** 延迟的时间,函数的调用会在该延迟之后发生,单位 ms。 */
  121. delay?: number,
  122. /** param1, param2, ..., paramN 等附加参数,它们会作为参数传递给回调函数。 */
  123. rest?: any
  124. ): number