Share via

Office script: Yield not functioning properly when console.log added to same function

Anonymous
2023-03-02T13:19:39+00:00

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

}
Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-03-02T15:36:02+00:00

    For office script, you can get help from Microsoft Power Automate Community.

    Microsoft Power Automate Community - Power Platform Community

    Best Regards,

    Snow Lu

    Was this answer helpful?

    0 comments No comments