With TypeScript 3.9, React Native, React Navigation...
I got error:
interface StackParamList
Type 'StackParamList' does not satisfy the constraint 'Record<string, object | undefined>'.
Index signature is missing in type 'StackParamList'.ts(2344)
on:
const HomeStack = createStackNavigator<StackParamList>()
In:
const HomeStack = createStackNavigator<StackParamList>()
export interface StackParamList {
Home: undefined
Post: { post: Post }
Category: { category: Category }
Login: undefined
ForgotPassword: undefined
'My profile': undefined
'My partner': undefined
Parameters: undefined
Likes: undefined
Onboarding: undefined
}
/**
* Home "stack navigator"
* @summary this is the navigator for everything located under "home"
*/
export default function HomeStackScreen() {
return (
<>
<StatusBar backgroundColor={colors.background} barStyle="dark-content" />
<HomeStack.Navigator screenOptions={screenOptions}>
<HomeStack.Screen
name="Home"
component={HomeScreen}
options={{
headerTitle: (props) => <Logo {...props} />,
}}
/>
<HomeStack.Screen name="Login" component={LoginScreen} />
<HomeStack.Screen name="Post" component={PostScreen} options={{ headerTransparent: true, title: '' }} />
<HomeStack.Screen name="Category" component={CategoryScreen} options={({ route }) => ({ title: route.params.category.id })} />
<HomeStack.Screen name="ForgotPassword" component={ForgotPasswordScreen} />
<HomeStack.Screen name="My profile" component={UserProfileScreen} options={{ headerTransparent: true, title: '' }} />
<HomeStack.Screen name="My partner" component={UserPartnerScreen} />
<HomeStack.Screen name="Parameters" component={UserParamScreen} />
<HomeStack.Screen name="Likes" component={UserLikesScreen} />
<HomeStack.Screen name="Onboarding" component={Onboarding} options={{ headerShown: false }} />
</HomeStack.Navigator>
</>
)
}
I don't understand why the interface would not satisfy the type 'Record<string, object | undefined>'.
I don't understand what "Index signature is missing" mean.
Do you have an idea?
Thanks