Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presence of generators result in Webpack compilation error #10

Open
poteat opened this issue Jan 17, 2020 · 2 comments
Open

Presence of generators result in Webpack compilation error #10

poteat opened this issue Jan 17, 2020 · 2 comments

Comments

@poteat
Copy link

poteat commented Jan 17, 2020

For background, see PR #9 adding failing unit tests for generators. Both compilation and serialization don't seem to work; target is set to ES5 but ES6 and ES3 were also attempted.

This is a very strange bug, as Typescript already polyfills generator support to ES5 in a very similar way that it does async/await support.

I am attaching the failing unit test results from the CLI.

  31 passing (11s)
  3 failing

  1) Serialization
       generator.ts:simpleGenerator:
     TypeError: Cannot read property 'label' of undefined
      at C:\Users\-\Desktop\Code\ts-serialize-closures\ts-closure-transform\test\serialization\generator.js:34:26
      at step (test\serialization\generator.js:23:23)
      at Object.next (test\serialization\generator.js:4:53)
      at Context.simpleGenerator (test\serialization\generator.js:47:26)
      at processImmediate (internal/timers.js:439:21)

  2) Serialization
       generator.ts:roundtripGenerator:
     ReferenceError: __generator is not defined
      at myGenerator (eval at _l (C:\Users\-\Desktop\Code\ts-serialize-closures\serialize-closures\src\serializedGraph.js:395:20), <anonymous>:2:5)
      at myGenerator (C:\Users\-\Desktop\Code\ts-serialize-closures\serialize-closures\src\serializedGraph.js:328:39)
      at Context.roundtripGenerator (test\serialization\generator.js:51:34)
      at processImmediate (internal/timers.js:439:21)

  3) Serialization
       generator.ts:roundtripGeneratorInProgress:
     TypeError: Cannot read property 'label' of undefined
      at C:\Users\-\Desktop\Code\ts-serialize-closures\ts-closure-transform\test\serialization\generator.js:34:26
      at step (test\serialization\generator.js:23:23)
      at Object.next (test\serialization\generator.js:4:53)
      at Context.roundtripGeneratorInProgress (test\serialization\generator.js:56:16)
      at processImmediate (internal/timers.js:439:21)
@lhoste-bell
Copy link
Collaborator

Thank you for reporting this issue.

It seems we inject invalid code in the switch statement switch (_a.value.label) should be switch (_a.label). I don't have time to look further into this at the moment, but I did add some comments in your PR.

@lhoste-bell
Copy link
Collaborator

0415304 fixes the invalid .value property injection. It's an interesting bug that I might report upstream (tsc). This fix allows the first unit test to succeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants