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

skewer-eval-defun doesn't recognize async javascript functions #86

Open
formido opened this issue Jan 18, 2018 · 3 comments
Open

skewer-eval-defun doesn't recognize async javascript functions #86

formido opened this issue Jan 18, 2018 · 3 comments

Comments

@formido
Copy link

formido commented Jan 18, 2018

Evaluating the following:

async function test_await() {
  response = await fetch('./api');
  json = await response.json();
  console.log(json);
}

...gives:

SyntaxError: await is only valid in async function

SyntaxError: await is only valid in async function
    at Array.eval (<anonymous>)
[...]

Expression:

function test_await() {
  response = await fetch('./api');
  json = await response.json();
  console.log(json);
}
@ghost
Copy link

ghost commented Apr 20, 2020

Same issue

@UwUnyaa
Copy link
Contributor

UwUnyaa commented Apr 21, 2020

Looks like an issue as to what skewer considers an expression.

This could be the culprit: https://github.com/skeeto/skewer-mode/blob/master/skewer-mode.el#L451

I might take a look at this later and try to tackle it, but it might require a bump to required version of js2-mode.

@UwUnyaa
Copy link
Contributor

UwUnyaa commented Apr 21, 2020

I haven't figured out a way to use js2-mode's API to check whether current function is async or not, or any other approach that could potentially work. It seems like code related to that is used while parsing, and can't be easily used to check whether point is at an async function. It's also worth noting that there's no node type for async token or anything like that. It might be worth asking the developer of js2-mode whether there's any way to do this for code using this mode's code.

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