Browse Source

Make push with passProps type safe (#4223)

Henrik Raitasola 6 years ago
parent
commit
e1b079ae9f
2 changed files with 5 additions and 5 deletions
  1. 1
    1
      lib/src/Navigation.ts
  2. 4
    4
      lib/src/interfaces/Layout.ts

+ 1
- 1
lib/src/Navigation.ts View File

116
   /**
116
   /**
117
    * Push a new layout into this screen's navigation stack.
117
    * Push a new layout into this screen's navigation stack.
118
    */
118
    */
119
-  public push(componentId: string, layout: Layout): Promise<any> {
119
+  public push<P>(componentId: string, layout: Layout<P>): Promise<any> {
120
     return this.commands.push(componentId, layout);
120
     return this.commands.push(componentId, layout);
121
   }
121
   }
122
 
122
 

+ 4
- 4
lib/src/interfaces/Layout.ts View File

1
 import { Options, OptionsSplitView } from './Options';
1
 import { Options, OptionsSplitView } from './Options';
2
 
2
 
3
-export interface LayoutComponent {
3
+export interface LayoutComponent<P = {}> {
4
   /**
4
   /**
5
    * Component reference id, Auto generated if empty
5
    * Component reference id, Auto generated if empty
6
    */
6
    */
16
   /**
16
   /**
17
    * Properties to pass down to the component
17
    * Properties to pass down to the component
18
    */
18
    */
19
-  passProps?: object;
19
+  passProps?: P;
20
 }
20
 }
21
 
21
 
22
 export interface LayoutStackChildren {
22
 export interface LayoutStackChildren {
118
   overlays?: any;
118
   overlays?: any;
119
 }
119
 }
120
 
120
 
121
-export interface Layout {
121
+export interface Layout<P = {}> {
122
   /**
122
   /**
123
    * Set the component
123
    * Set the component
124
    */
124
    */
125
-  component?: LayoutComponent;
125
+  component?: LayoutComponent<P>;
126
   /**
126
   /**
127
    * Set the stack
127
    * Set the stack
128
    */
128
    */