Pārlūkot izejas kodu

Make push with passProps type safe (#4223)

Henrik Raitasola 6 gadus atpakaļ
vecāks
revīzija
e1b079ae9f
2 mainītis faili ar 5 papildinājumiem un 5 dzēšanām
  1. 1
    1
      lib/src/Navigation.ts
  2. 4
    4
      lib/src/interfaces/Layout.ts

+ 1
- 1
lib/src/Navigation.ts Parādīt failu

@@ -116,7 +116,7 @@ export class Navigation {
116 116
   /**
117 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 120
     return this.commands.push(componentId, layout);
121 121
   }
122 122
 

+ 4
- 4
lib/src/interfaces/Layout.ts Parādīt failu

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