With in JS you can define default parameters and with flow you can type them. I wasn't careful and the following bug crept into production.
const somefunc = ({ hasExpiredToken = false }: { hasExpiredToken: boolean }) => {
doSomething({ hasExpiredToken, navigation });
};
It is not obvious but when the above function is called without arguements it will cause an error because even though
the propertes of the object have default values the object itself does not. So when the function is called, it will try
to destructure hasExpiredToken
from undefined
which will fail.
I had to call it with an empty object i.e. somefunc({})
or define a default value for the function like so:
const somefunc = ({ hasExpiredToken = false }: { hasExpiredToken: boolean } = {}) => {
doSomething({ hasExpiredToken, navigation });
};