From 97a38a7c056d1eca3cc8e357bc536b9ed6c64405 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 21 Jun 2018 23:13:24 +0800 Subject: [PATCH 1/3] add .use method to wepy app --- types/wepy/app.d.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/types/wepy/app.d.ts b/types/wepy/app.d.ts index cc2636ed92..9b970906a9 100644 --- a/types/wepy/app.d.ts +++ b/types/wepy/app.d.ts @@ -8,6 +8,25 @@ export interface AppConstructor { new (): app; } +/* the supported add-ons */ +type AddOn = "requestfix" | "promisify"; + +interface WindowConfig { + backgroundTextStyle: string; + navigationBarBackgroundColor: string; + navigationBarTitleText: string; + navigationBarTextStyle: string; +} + export default class app { - $init(wepy: any, config: AppConfig): any; + config: { + window: WindowConfig; + pages: string[]; + }; + $init(wepy: any, config: AppConfig): void; + use(addonName: AddOn, ...args: any[]): void; + $initAPI( + wepy: any, + noPromiseAPI: string[] | { [name: string]: boolean } + ): void; } From 7a2a27838e9b3dde3635bdb4e2c6f8141665b967 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 21 Jun 2018 23:15:34 +0800 Subject: [PATCH 2/3] adding test --- types/wepy/wepy-tests.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/wepy/wepy-tests.ts b/types/wepy/wepy-tests.ts index 9ed5462fb9..d9794f6e8b 100644 --- a/types/wepy/wepy-tests.ts +++ b/types/wepy/wepy-tests.ts @@ -1,5 +1,11 @@ import wepy from "wepy"; +export class MyApp extends wepy.app { + async onLoad() { + this.use("requestfix"); + } +} + export class MyComponent extends wepy.component { data = { reveal: false, From a8232ba65e3a53d8d124ff108a90778280722761 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 21 Jun 2018 23:21:43 +0800 Subject: [PATCH 3/3] fix lint --- types/wepy/app.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/wepy/app.d.ts b/types/wepy/app.d.ts index 9b970906a9..9389b0400f 100644 --- a/types/wepy/app.d.ts +++ b/types/wepy/app.d.ts @@ -9,9 +9,9 @@ export interface AppConstructor { } /* the supported add-ons */ -type AddOn = "requestfix" | "promisify"; +export type AddOn = "requestfix" | "promisify"; -interface WindowConfig { +export interface WindowConfig { backgroundTextStyle: string; navigationBarBackgroundColor: string; navigationBarTitleText: string;