1 |
|
2 |
|
3 |
|
4 | import Taro, { Config } from './index'
|
5 |
|
6 | declare module './index' {
|
7 |
|
8 | interface ComponentLifecycle<P, S, SS = any> extends NewLifecycle<P, S, SS> {
|
9 | componentWillMount?(): void
|
10 | componentDidMount?(): void
|
11 | componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void
|
12 | shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): boolean
|
13 | componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void
|
14 | componentWillUnmount?(): void
|
15 | componentDidShow?(): void
|
16 | componentDidHide?(): void
|
17 | componentDidCatchError?(err: string): void
|
18 | componentDidNotFound?(obj: PageNotFoundObject): void
|
19 | onPullDownRefresh?(): void
|
20 | onReachBottom?(): void
|
21 | onPageScroll?(obj: PageScrollObject): void
|
22 | onShareAppMessage?(obj: ShareAppMessageObject): ShareAppMessageReturn
|
23 | onTabItemTap?(obj: TabItemTapObject): void
|
24 | onResize?(obj: PageResizeObject): void
|
25 | }
|
26 | interface ComponentOptions {
|
27 | addGlobalClass?: boolean
|
28 | styleIsolation?: 'isolated' | 'apply-shared' | 'shared'
|
29 | }
|
30 | interface ComponentClass<P = {}, S = any> extends StaticLifecycle<P, S> {
|
31 | new (...args: any[]): Component<P, {}>
|
32 | propTypes?: any
|
33 | defaultProps?: Partial<P>
|
34 | displayName?: string
|
35 | }
|
36 |
|
37 | interface RouterInfo<TParams extends Partial<Record<string, string>> = Partial<Record<string, string>>> {
|
38 |
|
39 | params: TParams
|
40 |
|
41 |
|
42 | path: string
|
43 |
|
44 | onReady: string
|
45 | onHide: string
|
46 | onShow: string
|
47 |
|
48 | shareTicket: string | undefined
|
49 | scene: number | undefined
|
50 | }
|
51 | interface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> {
|
52 | $scope?: any
|
53 | }
|
54 | type PropsWithChildren<P> = P & { children?: React.ReactNode }
|
55 | interface FunctionComponent<P = {}> {
|
56 | (props: PropsWithChildren<P>, context?: any): React.ReactElement | null
|
57 | propTypes?: any
|
58 | defaultProps?: Partial<P>
|
59 | config?: Config
|
60 | options?: ComponentOptions
|
61 | externalClasses?: string[]
|
62 | }
|
63 | type FC<P = {}> = FunctionComponent<P>
|
64 | interface StatelessFunctionComponent {
|
65 | (): JSX.Element
|
66 | }
|
67 | type SFC = StatelessFunctionComponent
|
68 |
|
69 | interface Show {
|
70 | componentDidShow?(): void
|
71 | componentDidHide?(): void
|
72 | onShow?(): void
|
73 | onHide?(): void
|
74 | }
|
75 | interface AppInstance extends Show {
|
76 | mount(component: React.ComponentClass | Vue.ComponentOptions<Vue>, id: string, cb: () => void): void
|
77 | componentDidShow?(options?: Record<string, unknown>): void
|
78 | onShow?(options?: Record<string, unknown>): void
|
79 | unmount(id: string, cb: () => void): void
|
80 | }
|
81 | type Target = Record<string, unknown> & { dataset: Record<string, unknown>; id: string }
|
82 | interface MpEvent {
|
83 | type: string
|
84 | detail: Record<string, unknown>
|
85 | target: Target
|
86 | currentTarget: Target
|
87 | }
|
88 | interface PageLifeCycle extends Show {
|
89 | onPullDownRefresh?(): void
|
90 | onReachBottom?(): void
|
91 | onPageScroll?(obj: { scrollTop: number }): void
|
92 | onShareAppMessage?(obj: { from: string; target?: any; webViewUrl: string }): void
|
93 | onResize?(options: unknown): void
|
94 | onTabItemTap?(obj: { index: string; pagePath: string; text: string }): void
|
95 | onTitleClick?(): void
|
96 | onOptionMenuClick?(): void
|
97 | onPopMenuClick?(): void
|
98 | onPullIntercept?(): void
|
99 | eh?(event: MpEvent): void
|
100 | onLoad(options: Record<string, unknown>): void
|
101 | onUnload(): void
|
102 | }
|
103 | interface ComponentInstance<
|
104 | TData extends Record<string, unknown> = Record<string, unknown>,
|
105 | TParams extends Record<string, string> = Record<string, string>
|
106 | > {
|
107 |
|
108 | is?: string
|
109 |
|
110 | id?: string
|
111 |
|
112 | dataset?: string
|
113 |
|
114 | data?: TData
|
115 |
|
116 | properties?: TData
|
117 |
|
118 | router?: RouterInfo<TParams>
|
119 |
|
120 | pageRouter?: RouterInfo<TParams>
|
121 |
|
122 | setData?(newData: Partial<TData>): void
|
123 |
|
124 | hasBehavior?(behavior: unknown): boolean
|
125 |
|
126 | triggerEvent?(name: string, detail: Record<string, unknown>, options: {
|
127 |
|
128 | bubbles?: boolean
|
129 |
|
130 | composed?: boolean
|
131 |
|
132 | capturePhase?: boolean
|
133 | }): void
|
134 |
|
135 | createSelectorQuery?(): SelectorQuery
|
136 |
|
137 | createIntersectionObserver?(): IntersectionObserver
|
138 |
|
139 | createMediaQueryObserver?(): MediaQueryObserver
|
140 |
|
141 | selectComponent?<
|
142 | TD extends Record<string, unknown> = Record<string, unknown>,
|
143 | TP extends Record<string, string> = Record<string, string>
|
144 | >(selector: string): ComponentInstance<TD, TP>
|
145 |
|
146 | selectAllComponents?<
|
147 | TD extends Record<string, unknown> = Record<string, unknown>,
|
148 | TP extends Record<string, string> = Record<string, string>
|
149 | >(selector: string): ComponentInstance<TD, TP>
|
150 |
|
151 | selectOwnerComponent?<
|
152 | TD extends Record<string, unknown> = Record<string, unknown>,
|
153 | TP extends Record<string, string> = Record<string, string>
|
154 | >(): ComponentInstance<TD, TP>
|
155 |
|
156 | getRelationNodes?(relationKey: string): NodesRef[]
|
157 |
|
158 | groupSetData?(callback: () => void): void
|
159 | /** 返回当前页面的 custom-tab-bar 的组件实例,详见[自定义 tabBar](https:
|
160 | getTabBar?(): ComponentInstance
|
161 |
|
162 | getPageId?(): string
|
163 |
|
164 | animate?(selector: string, keyFrames: KeyFrame[], duration: number, callback: () => void): void
|
165 |
|
166 | animate?(selector: string, keyFrames: KeyFrame[], duration: number, scrollTimeline: ScrollTimelineOption): void
|
167 |
|
168 | clearAnimation?(selector: string, callback: () => void): void
|
169 |
|
170 | clearAnimation?(selector: string, options: ClearAnimationOptions, callback: () => void): void
|
171 |
|
172 | setUpdatePerformanceListener?(options: {
|
173 |
|
174 | withDataPaths?: boolean
|
175 | }, listener: () => void): void
|
176 | }
|
177 | interface PageInstance extends PageLifeCycle, ComponentInstance {
|
178 |
|
179 | config?: PageConfig
|
180 | data?: Record<string, unknown>
|
181 | path?: string
|
182 | options?: Record<string, unknown>
|
183 | }
|
184 | interface TaroStatic {
|
185 | memo<P = {}>(
|
186 | FunctionComponent: FunctionComponent<P>,
|
187 | compare?: (oldProps: P, newProps: P) => boolean
|
188 | ): FunctionComponent<P>
|
189 | }
|
190 | }
|
191 |
|
\ | No newline at end of file |