¿Por qué este fragmento de código foreach es inválido en Angularjs?

private calculateTotal(order: InventoryOrder):number{
    let total = 0.0;
    if(order && order.currentInventory){
        order.currentInventory.forEach(x =>{
            console.log(x.quantity);
            console.log("helloworld");
        });
    } 
    return total;
}
SAMER SAEID