index.d.ts 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*! *****************************************************************************
  2. Copyright (c) 2021 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 { success: any }
  37. ? void
  38. : P extends { fail: any }
  39. ? void
  40. : P extends { complete: any }
  41. ? void
  42. : Promise<Parameters<Exclude<T['success'], undefined>>[0]>
  43. }
  44. declare const console: WechatMiniprogram.Console
  45. declare const wx: WechatMiniprogram.Wx
  46. /** 引入模块。返回模块通过 `module.exports` 或 `exports` 暴露的接口。 */
  47. declare function require(
  48. /** 需要引入模块文件相对于当前文件的相对路径,或 npm 模块名,或 npm 模块路径。不支持绝对路径 */
  49. module: string
  50. ): any
  51. /** 引入插件。返回插件通过 `main` 暴露的接口。 */
  52. declare function requirePlugin(
  53. /** 需要引入的插件的 alias */
  54. module: string
  55. ): any
  56. /** 插件引入当前使用者小程序。返回使用者小程序通过 [插件配置中 `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)。
  57. *
  58. * 该接口只在插件中存在
  59. *
  60. * 最低基础库: `2.11.1` */
  61. declare function requireMiniProgram(): any
  62. /** 当前模块对象 */
  63. declare let module: {
  64. /** 模块向外暴露的对象,使用 `require` 引用该模块时可以获取 */
  65. exports: any
  66. }
  67. /** `module.exports` 的引用 */
  68. declare let exports: any