/// /// /// /// declare namespace Agree { // Components interface ComponentLifecycle extends NewLifecycle { componentWillMount?(): void componentDidMount?(): void componentWillReceiveProps?(nextProps: Readonly

, nextContext: any): void shouldComponentUpdate?(nextProps: Readonly

, nextState: Readonly, nextContext: any): boolean componentWillUpdate?(nextProps: Readonly

, nextState: Readonly, nextContext: any): void componentWillUnmount?(): void componentDidShow?(): void componentDidHide?(): void componentDidCatchError?(err: string): void componentDidNotFound?(obj: PageNotFoundObject): void onPullDownRefresh?(): void onReachBottom?(): void onPageScroll?(obj: PageScrollObject): void onShareAppMessage?(obj: ShareAppMessageObject): ShareAppMessageReturn onTabItemTap?(obj: TabItemTapObject): void onResize?(obj: any): void } interface ComponentOptions { addGlobalClass?: boolean styleIsolation?: 'isolated' | 'apply-shared' | 'shared' } interface ComponentClass

extends StaticLifecycle { new (...args: any[]): Component propTypes?: any // TODO: Use prop-types type definition. defaultProps?: Partial

displayName?: string } // ref: packages/agree-runtime/src/current.ts interface RouterInfo> = Partial>> { /** * 路由参数。 */ params: TParams /** * 页面路径。 */ path: string onReady: string onHide: string onShow: string shareTicket: string | undefined scene: number | undefined } interface Component

extends ComponentLifecycle { $scope?: any } class Component { constructor(props?: Readonly

) /** * @deprecated * @see https://reactjs.org/docs/legacy-context.html */ constructor(props?: P, context?: any) config?: Config options?: ComponentOptions $componentType: 'PAGE' | 'COMPONENT' $router: RouterInfo $preloadData: any /** * 使用 `this.$preload` 函数进行页面跳转传参 * @example this.$preload('key', 'val'); * @example this.$preload({ x: 1, y: 2 }); * @see https://nervjs.github.io/agree/docs/best-practice.html */ $preload(key: string, value: any): void $preload(key: object): void setState( state: ((prevState: Readonly, props: P) => Pick | S) | (Pick | S), callback?: () => any ): void forceUpdate(callBack?: () => any): void render(): React.ReactNode readonly props: Readonly

& Readonly<{ children?: React.ReactNode }> state: Readonly context: any refs: { [key: string]: any } } type PropsWithChildren

= P & { children?: React.ReactNode } interface FunctionComponent

{ (props: PropsWithChildren

, context?: any): React.ReactElement | null propTypes?: any // TODO: Use prop-types type definition. defaultProps?: Partial

config?: Config options?: ComponentOptions externalClasses?: string[] } type FC

= FunctionComponent

interface StatelessFunctionComponent { (): JSX.Element } type SFC = StatelessFunctionComponent class PureComponent

extends Component {} function memo

( FunctionComponent: FunctionComponent

, compare?: (oldProps: P, newProps: P) => Boolean ): FunctionComponent

interface Show { componentDidShow?(options?: unknown): void componentDidHide?(options?: unknown): void onShow?(options?: unknown): void onHide?(options?: unknown): void } interface AppInstance extends Show { mount(component: React.ComponentClass | Vue.ComponentOptions, id: string, cb: () => void): void unmount(id: string, cb: () => void): void } type Target = Record & { dataset: Record; id: string } interface MpEvent { type: string detail: Record target: Target currentTarget: Target } interface PageLifeCycle extends Show { onPullDownRefresh?(): void onReachBottom?(): void onPageScroll?(obj: { scrollTop: number }): void onShareAppMessage?(obj: { from: string; target?: any; webViewUrl: string }): void onResize?(options: unknown): void onTabItemTap?(obj: { index: string; pagePath: string; text: string }): void onTitleClick?(): void onOptionMenuClick?(): void onPopMenuClick?(): void onPullIntercept?(): void eh?(event: MpEvent): void onLoad(options: Record): void onUnload(): void } interface PageInstance extends PageLifeCycle { /** * 页面配置。 */ config?: PageConfig data?: Record path?: string options?: Record /** * 执行关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html) * * 最低基础库版本:[`2.9.0`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) **/ animate?(selector: string, keyFrames: KeyFrame[], duration: number, callback: () => void): void /** * 执行关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html) * * 最低基础库版本:[`2.9.0`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) **/ animate?( selector: string, keyFrames: ScrollTimelineKeyframe[], duration: number, scrollTimeline: ScrollTimelineOption ): void /** * 清除关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html) * * 最低基础库版本:[`2.9.0`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) **/ clearAnimation?(selector: string, callback: () => void): void /** * 清除关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html) * * 最低基础库版本:[`2.9.0`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) **/ clearAnimation?(selector: string, options: ClearAnimationOptions, callback: () => void): void } }