try flow
declare function gen(): [Error, null] | [null, number];
const [err, number] = gen();
if (!err) {
(number: number)
}
that last cast throws an error that number can be null even though the if statement should force (err: null) and (number: number)
Any suggestions on how to re-write this would be appreciated!