Просмотр исходного кода

Added typed interface for all known constants (#4452)

Adam Pietrasiak 6 лет назад
Родитель
Сommit
a71e7311e2
1 измененных файлов: 10 добавлений и 3 удалений
  1. 10
    3
      lib/src/adapters/Constants.ts

+ 10
- 3
lib/src/adapters/Constants.ts Просмотреть файл

@@ -1,9 +1,16 @@
1 1
 import { NativeModules } from 'react-native';
2 2
 
3
+export interface NavigationConstants {
4
+  statusBarHeight: number;
5
+  backButtonId: string;
6
+  topBarHeight: number;
7
+  bottomTabsHeight: number;
8
+}
9
+
3 10
 export class Constants {
4
-  static async get(): Promise<any> {
11
+  static async get(): Promise<NavigationConstants> {
5 12
     if (!this.instance) {
6
-      const constants = await NativeModules.RNNBridgeModule.getConstants();
13
+      const constants: NavigationConstants = await NativeModules.RNNBridgeModule.getConstants();
7 14
       this.instance = new Constants(constants);
8 15
     }
9 16
     return this.instance;
@@ -16,7 +23,7 @@ export class Constants {
16 23
   public readonly topBarHeight: number;
17 24
   public readonly bottomTabsHeight: number;
18 25
 
19
-  private constructor(constants) {
26
+  private constructor(constants: NavigationConstants) {
20 27
     this.statusBarHeight = constants.statusBarHeight;
21 28
     this.topBarHeight = constants.topBarHeight;
22 29
     this.backButtonId = constants.backButtonId;