type Optional = F extends (arg: infer P) => infer R ? (arg?: P) => R : F type OptionalInterface = { [K in keyof T]: Optional } interface InstanceMethod { sendFile: (path: string, opts: Record) => any download: (url: string, opts?: Record) => any httpRequest: (data: { url: string method: string headers?: Record body?: Record timeout?: number }) => Promise<{ status: number statusText: string headers: Record body: any }> fetch: (data: { url: string method: string headers?: Record body?: Record timeout?: number }) => Promise request: (data: { method: string params: Record }) => Promise call: (data: { method: string; params: Record }) => void } interface CallBackInterface { onReceivedFile: (fileObj: any) => void onRequest: ( req: { method: string; params: Record }, res: (error: any, data: any) => void, ) => any onCall: (data: { method: string; params: Record }) => any onSettingsChange: (value: { key: string newValue: any oldValue: any }) => any } type AnyFunction = (options: string) => any declare module '@zeppos/zml/base-app' { type Instance< TData extends DataOption, TCustom extends CustomOption, > = OptionalInterface & Data & TCustom type Options< TData extends DataOption, TCustom extends CustomOption, > = (TCustom & Partial> & Partial) & ThisType> interface ILifeCycle { onCreate: AnyFunction onDestroy: AnyFunction } interface Data { _options: this globalData: D & { messaging: any } } type DataOption = Record type CustomOption = Record interface Constructor { ( options: Options, ): any use(opts: (instance: any, ...args: any[]) => this | any): this } let BaseApp: Constructor } declare module '@zeppos/zml/base-page' { type Instance< TData extends DataOption, TCustom extends CustomOption, > = OptionalInterface & Omit & Data & TCustom type Options< TData extends DataOption, TCustom extends CustomOption, > = (TCustom & Partial> & Partial & Partial>) & ThisType> interface ILifeCycle { onInit: AnyFunction onResume: AnyFunction build: AnyFunction onPause: AnyFunction onDestroy: AnyFunction } type DataOption = Record type CustomOption = Record interface Data { _options: this state: D } interface Constructor { ( options: Options, ): any use(opts: (instance: any, ...args: any[]) => this | any): this } let BasePage: Constructor } declare module '@zeppos/zml/base-side' { type Instance< TData extends DataOption, TCustom extends CustomOption, > = OptionalInterface & Omit & Data & TCustom type Options< TData extends DataOption, TCustom extends CustomOption, > = (TCustom & Partial> & Partial & Partial) & ThisType> interface ILifeCycle { onInit: AnyFunction onRun: AnyFunction onDestroy: AnyFunction } type DataOption = Record type CustomOption = Record interface Data { state: D } interface Constructor { ( options: Options, ): any use(opts: (instance: any, ...args: any[]) => this | any): this } let BaseSideService: Constructor interface ISettingsLib { getItem(i: string): any setItem(i: string, v: any): any clear(): void removeItem(i: string): void getAll(): any } let settingsLib: ISettingsLib interface IConvertLib { convert(opts: any): Promise } let convertLib: IConvertLib }