UNPKG

1.75 kBTypeScriptView Raw
1import Taro from '../../index'
2
3declare module '../../index' {
4 /** 注册小程序中的一个页面。接受一个 `Object` 类型参数,其指定页面的初始数据、生命周期回调、事件处理函数等。 */
5 interface Page {
6 /**
7 * 当前页面的路径
8 */
9 route: string
10 /** @ignore */
11 [k: string]: any
12 }
13
14 namespace getApp {
15 interface Option {
16 /** 在 `App` 未定义时返回默认实现。当App被调用时,默认实现中定义的属性会被覆盖合并到App中。一般用于独立分包 */
17 allowDefault?: boolean
18 }
19 type Instance<T extends App> = Option & T
20 }
21
22 /** 注册小程序。接受一个 `Object` 参数,其指定小程序的生命周期回调等。
23 * @ignore
24 */
25 interface App extends TaroGeneral.IAnyObject {
26 /** @ignore */
27 [key: string]: any
28 }
29
30 interface TaroStatic {
31 /** 获取当前页面栈。数组中第一个元素为首页,最后一个元素为当前页面。
32 * __注意:__
33 * - __不要尝试修改页面栈,会导致路由以及页面状态错误。__
34 * - 不要在 `App.onLaunch` 的时候调用 `getCurrentPages()`,此时 `page` 还没有生成。
35 * @supported weapp, h5
36 * @example
37 * ```tsx
38 * Taro.getCurrentPages().length
39 * ```
40 * @see https://developers.weixin.qq.com/miniprogram/dev/reference/api/getCurrentPages.html
41 */
42 getCurrentPages(): Page[]
43
44 /** 获取到小程序全局唯一的 App 实例。
45 * @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
46 * @see https://developers.weixin.qq.com/miniprogram/dev/reference/api/getApp.html
47 */
48 getApp<T = TaroGeneral.IAnyObject>(opts?: getApp.Option): getApp.Instance<T>
49 }
50}