There appears to be a bug in Office Scripts when using yield and console.log. The well-known yield sample is at the bottom. I expect to see the following in the output:
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
Short of removing the yield altogether, I have yet to find a workaround.
Code sample:
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
}