for sure my logic in much more complicated but here is a placeholder code where I am trying to stop a recursive call but break keyword says Jump target cannot cross function boundary .ts(1107)
let arr = [1, 2, 3, 4, 5, 6, 7, 8];
async function recCall(input: number[]) {
    if (input.length) {
        let eachItem = input.pop();
        // my logic includes http call with await
        recCall(input); // next iter
    }else{
        break; // says error 
    }
};
this is not plain javascript but typescript, my typescript version is:
tsc -v 
 Version 3.7.5
I am unable to understand what does this error means and why it is occuring, I searched on the internet but didn't found any reasons, I have been using break for breaking loops past years and now it is apparently started not working and saying an error I do not understand any help would be appriciated.
You don't have a loop to break from. You are calling your function recursively, this is not the same as a loop. Use return instead of break:
let arr = [1, 2, 3, 4, 5, 6, 7, 8];
async function recCall(input: number[]) {
  if (input.length) {
    let eachItem = input.pop();
    // my logic includes http call with await
    recCall(input); // next iter
  }else{
    return;
  }
};
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With