title: CompositeNavigationProp, 'undefined' is not assignable to type '{ a: ParamListBase; b: string; c: {}; }'
body: <p>In my ReactNative application, I have defined a stack-drawer composition like below</p>
  <pre class="lang-typescript prettyprint-override"><code>const Auth = createStackNavigator&lt;AuthStackParamList&gt;();
  const Main = createStackNavigator&lt;MainStackParamList&gt;();
  const Drawer = createDrawerNavigator&lt;DrawerParamList&gt;();
  
  const AuthStack = () =&gt; (
    &lt;Auth.Navigator initialRouteName=&quot;LoginScreen&quot;&gt;
      &lt;Auth.Screen name=&quot;LoginScreen&quot; component={LoginScreen} /&gt;
      &lt;Auth.Screen name=&quot;SignUpScreen&quot; component={SignUpScreen} /&gt;
    &lt;/Auth.Navigator&gt;
  );
  // In order to have access to &quot;openDrawer()&quot;  I had to make a composite type (types.ts)
  const MainStack = ({navigation}: {navigation: MainNavigationProps}) =&gt; (
    &lt;Main.Navigator  initialRouteName=&quot;DashboardScreen&quot;&gt;
      &lt;Main.Screen
        name=&quot;ProfileScreen&quot;
        component={ProfileScreen}
        options={{
          headerLeft: () =&gt; &lt;IconButton onPress={() =&gt; navigation.openDrawer()} /&gt;
        }}
      /&gt;
      &lt;Main.Screen
        name=&quot;DashboardScreen&quot;
        component={DashboardScreen}
        options={{
          headerLeft: () =&gt; &lt;IconButton onPress={() =&gt; navigation.openDrawer()} /&gt;
        }}
      /&gt;
      &lt;Main.Screen
        name=&quot;SettingScreen&quot;
        component={SettingScreen}
        options={{
          headerLeft: () =&gt; &lt;IconButton onPress={() =&gt; navigation.openDrawer()} /&gt;
        }}
      /&gt;
    &lt;/Main.Navigator&gt;
  );
  
  // And this component (Navigation.tsx) returns 
   &lt;NavigationContainer &gt;
        {isAuthenticated ? (
          &lt;Drawer.Navigator
            initialRouteName=&quot;MainStack&quot;
            drawerContent={(prop) =&gt; &lt;DrawerComponent {...prop} /&gt;}&gt;
            &lt;Drawer.Screen name=&quot;MainStack&quot; component={MainStack} /&gt;
          &lt;/Drawer.Navigator&gt;
        ) : (
          &lt;AuthStack /&gt;
        )}
   &lt;/NavigationContainer&gt;
  </code></pre>
  <p>And in the <code>types.ts</code> have defined types like</p>
  <pre class="lang-typescript prettyprint-override"><code>import {CompositeNavigationProp} from '@react-navigation/core';
  import {DrawerNavigationProp} from '@react-navigation/drawer';
  import {StackNavigationProp} from '@react-navigation/stack';
  
  export type AuthStackParamList = {
    LoginScreen: undefined;
    SignUpScreen: undefined;
  };
  
  export type MainStackParamList = {
    ProfileScreen: undefined;
    DashboardScreen: undefined;
    SettingScreen: {id: number};
  };
  
  export type DrawerParamList = {
    MainStack: MainStackParamList;
  };
  
  export type MainNavigationProps = CompositeNavigationProp&lt;
    StackNavigationProp&lt;MainStackParamList&gt;, // &lt;---- The type error in this line
    DrawerNavigationProp&lt;DrawerParamList&gt;
  &gt;;
  </code></pre>
  <p>But I get the type error in the mentioned line as;</p>
  <pre class="lang-typescript prettyprint-override"><code> Type 'StackNavigationProp&lt;MainStackParamList, string&gt;' does not
   satisfy the constraint 'NavigationProp&lt;ParamListBase, string, any,
   any, {}&gt;'.   Type 'StackNavigationProp&lt;MainStackParamList, string&gt;' is
   not assignable to type 'PrivateValueStore&lt;ParamListBase, string, {}&gt;'.
       Types of property '''' are incompatible.
         Type '({ a: MainStackParamList; b: keyof MainStackParamList; c: {}; } &amp; { a: MainStackParamList; b: string; c:
   StackNavigationEventMap; }) | undefined' is not assignable to type '{
   a: ParamListBase; b: string; c: {}; }'.
           Type 'undefined' is not assignable to type '{ a: ParamListBase; b: string; c: {}; }'.ts(2344)
  </code></pre>
  <p>Are these the correct construction when you have a stack as the direct child of a drawer, and the way to define types for them? If so how should I get rid of the error? I could not undrestand the source fo the error.</p>