Topic on Project:Support desk

Jump to navigation Jump to search

Async functions unrecognized by JS parser

13
FunPL (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)

FunPL (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

FunPL (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...

FunPL (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?

FunPL (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

FunPL (talkcontribs)

Still doesn't work. Tested it

This post was hidden by FunPL (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"