Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I resolve 'Argument types do not match parameters' in TypeScript with React Navigation?

I try to use Typescript in ReactNavigation, and got error by IDE (webstorm)

My Navigator:

export type RootStackParamList = {
    AppStack: undefined;
    AuthStack: undefined;
};

const RootStack = createStackNavigator<RootStackParamList>();

const Navigation: React.FunctionComponent = () => {
    return (
        <RootStack.Navigator>
            <RootStack.Screen name="AuthStack" component={AuthStack} />
            <RootStack.Screen name="AppStack" component={AppStack} />
        </RootStack.Navigator>
    );
}

My LoginScreen in AuthStack:

type NavigationProps = StackNavigationProp<RootStackParamList>;
const LoginScreen = () => {
    const navigation = useNavigation<StackNavigationProp<RootStackParamList>>();
    const requestLogin = () => {
        navigation.navigate('AppStack');  // IDE show error in 'AppStack'
    }
}

I run app and everything ok, but the IDE still show error: Argument types do not match parameters. It isn't an eslint error.

How can I fix this error?

like image 463
DinhNguyen Avatar asked Mar 25 '26 15:03

DinhNguyen


1 Answers

Seems like it's a bug of old version of Webstorm. I just update Webstorm to 2023.2.5 and the error disappear

like image 112
DinhNguyen Avatar answered Mar 28 '26 06:03

DinhNguyen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!