Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Weird error message when calling yield from a standard function #530

Closed
msageryd opened this issue May 18, 2017 · 3 comments
Closed

Weird error message when calling yield from a standard function #530

msageryd opened this issue May 18, 2017 · 3 comments

Comments

@msageryd
Copy link

I made the mistake of calling yield from a non-generator function. Actually an anonymous function. I would probably have understood my mistake sooner if I'd got a better error message.

It would be great with a better error message so the next generator-newbie doesn't have to struggle as much :)

I got "SyntaxError: yield is a reserved word".

Here is the code that got me the error:

function* saveUnsavedJournalItemsToServer() {
  const journalItemsToSave = yield select(selectCompletedUnsavedJournalItems);
  journalItemsToSave.map(journalItem => {
    yield fork(saveJournalItemToServer, journalItem);
  }); 
}

Here is the complete output.

journalSagas.js: SyntaxError: yield is a reserved word (177:4)
  175 |
  176 |   journalItemsToSave.map(journalItem => {
> 177 |     yield fork(saveJournalItemToServer, journalItem);
      |     ^
  178 |   });
  179 | }
  180 |
@hzoo
Copy link
Member

hzoo commented May 18, 2017

Hey @msageryd! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@hzoo
Copy link
Member

hzoo commented May 18, 2017

This is a similar issue to #113 (await in a non async function)

@babel-bot
Copy link

This issue has been moved to babel/babel#6693.

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

No branches or pull requests

3 participants