
There appears to be a bug in Office Scripts when using yield and console.log. Using a standard yield sample as a reference...
function* foo(index: number) {
// console.log('uncommenting will cause the yield not to function properly')
while (index < 2) {
yield index;
index++;
}
}
function main(workbook: ExcelScript.Workbook) {
const iterator = foo(0);
console.log(iterator.next().value); // Expected output: 0
console.log(iterator.next().value); // Expected output: 1
}
I expect to see:
uncommenting will cause the yield not to function properly
0
1
but instead I see:
uncommenting will cause the yield not to function properly
undefined
undefined
Is this a known issue? Any suggestions on a workaround besides not yielding?
A flow treats an office script as a black box. (sometimes) function parameter are provided, and an output is collected (usually a scalar value). Any console printing activities inside the office script will likely go into the void as the Power Automate flow doesn't have a concept of "console" .