-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
SyntaxError: yield is a reserved word #1624
Comments
You call yield in a normal function but it is only allowed in a generator. I might be wrong but I think the correct code is: function* saveUnsavedJournalItemsToServer() {
const journalItemsToSave = yield select(selectCompletedUnsavedJournalItems);
yield* journalItemsToSave.map(function* (journalItem) {
yield call(saveJournalItemToServer, journalItem);
});
} |
Ah, thanks. So, Prettier did a good job catching the problem. Maybe a better error message would be good, if possible. |
That's the error message from either babel or flow because prettier uses them to parse your code. :) If you want to learn more about generators take a look at http://exploringjs.com/es6/ch_generators.html |
Thanks again. I'll read up some more on the subject. Also, the "yield call" will probably make funny stuff happen. I have now changed to "yield fork". |
This is maybe a rare occation where a good old for-loop comes in handy (instead of map or each). No messing around with nested generators needed. |
The error message is indeed super confusing. If you could open an issue on babylon and flow projects to get it improved that would be awesome! |
I don't know if Flow would give this error as well. I don't use Flow anymore, so I presume it was Babel who gave the error. |
I get "SyntaxError: yield is a reserved word" from Prettier.
The function is a generator function used in a ReduxSaga:
Here is the complete output.
Is this a Prettier bug, or is my code flawed?
The text was updated successfully, but these errors were encountered: