Topic on Project:Support desk

Async functions unrecognized by JS parser

13
Fumple (talkcontribs)

Why are async functions considered invalid/unrecognized by MediaWiki's parser?

var function = async function(){

}

"JavaScript parse error: Parse error: Missing ; before statement in file"

DannyS712 (talkcontribs)

I think so - I always see that error (and ignore it)

Fumple (talkcontribs)

I can't ignore it, because I need a async function.

DannyS712 (talkcontribs)

I mean I ignore the error, because the code works fine

Fumple (talkcontribs)

I can't ignore it, because if this error occurs it never executes the code

DannyS712 (talkcontribs)

It isn't executed for you? It always is for me...

Fumple (talkcontribs)

Yeah, it simply throws this error

JavaScript parse error: Parse error: Missing ; before statement in file 'User:FunPL/common.js' on line 37

and it doesn't execute the code.

DannyS712 (talkcontribs)

case you post a snippet of the code?

Fumple (talkcontribs)

async function help(){

alert("Works?")

}

help()

Tested this snippet just now and it doesn't work, if I remove 'async' it works

DannyS712 (talkcontribs)

in this case you truly are missing semicolons - you need one at the end of alert, and another after you call help

Fumple (talkcontribs)

Still doesn't work. Tested it

This post was hidden by Fumple (history)
TheDJ (talkcontribs)

MediaWiki JS pages are still on ES5. They do not officially support syntax that is newer than that.

Reply to "Async functions unrecognized by JS parser"