Merge pull request #11 from fkling/export_async
Support async functions in export declarations
This commit is contained in:
commit
804481aad8
2
acorn.js
2
acorn.js
@ -3139,7 +3139,7 @@
|
||||
function parseExport(node) {
|
||||
next();
|
||||
// export var|const|let|function|class ...;
|
||||
if (tokType === _var || tokType === _const || tokType === _let || tokType === _function || tokType === _class) {
|
||||
if (tokType === _var || tokType === _const || tokType === _let || tokType === _function || tokType === _class || tokType === _name && tokVal === 'async') {
|
||||
node.declaration = parseStatement();
|
||||
node['default'] = false;
|
||||
node.specifiers = null;
|
||||
|
||||
@ -20,6 +20,7 @@ for (var i = 2; i < process.argv.length; ++i) {
|
||||
else if (arg == "--ecma3") options.ecmaVersion = 3;
|
||||
else if (arg == "--ecma5") options.ecmaVersion = 5;
|
||||
else if (arg == "--ecma6") options.ecmaVersion = 6;
|
||||
else if (arg == "--ecma7") options.ecmaVersion = 7;
|
||||
else if (arg == "--strictSemicolons") options.strictSemicolons = true;
|
||||
else if (arg == "--locations") options.locations = true;
|
||||
else if (arg == "--silent") silent = true;
|
||||
|
||||
@ -1901,6 +1901,45 @@ test('var obj = { async() {} };', {
|
||||
ecmaVersion: 7
|
||||
});
|
||||
|
||||
test('export async function foo(){}', {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 29,
|
||||
"body": [{
|
||||
"type": "ExportDeclaration",
|
||||
"start": 0,
|
||||
"end": 29,
|
||||
"declaration": {
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 7,
|
||||
"end": 29,
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 22,
|
||||
"end": 25,
|
||||
"name": "foo"
|
||||
},
|
||||
"params": [],
|
||||
"defaults": [],
|
||||
"rest": null,
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 27,
|
||||
"end": 29,
|
||||
"body": []
|
||||
},
|
||||
"expression": false
|
||||
},
|
||||
"default": false,
|
||||
"specifiers": null,
|
||||
"source": null
|
||||
}]
|
||||
}, {
|
||||
ecmaVersion: 7
|
||||
});
|
||||
|
||||
// ES7: Abstract references
|
||||
|
||||
test('foo::bar;', {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user