Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Commit

Permalink
Fix: Set async on async FunctionExpressions (fixes #244) (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
azz authored and JamesHenry committed Apr 30, 2017
1 parent 7c00f16 commit a294afa
Show file tree
Hide file tree
Showing 3 changed files with 333 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ast-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ module.exports = function(ast, extra) {
generator: !!node.asteriskToken,
params: node.parameters.map(convertChild),
body: convertChild(node.body),
async: hasModifier(SyntaxKind.AbstractKeyword, node),
async: hasModifier(SyntaxKind.AsyncKeyword, node),
expression: false
});
// Process returnType
Expand Down
330 changes: 330 additions & 0 deletions tests/fixtures/typescript/basics/async-function-expression.result.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,330 @@
module.exports = {
"type": "Program",
"range": [
0,
30
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"range": [
0,
30
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 5
}
},
"expression": {
"type": "CallExpression",
"range": [
0,
29
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 4
}
},
"callee": {
"type": "FunctionExpression",
"range": [
1,
26
],
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 2,
"column": 1
}
},
"id": {
"type": "Identifier",
"range": [
16,
20
],
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 20
}
},
"name": "test"
},
"generator": false,
"params": [],
"body": {
"type": "BlockStatement",
"range": [
23,
26
],
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 2,
"column": 1
}
},
"body": []
},
"async": true,
"expression": false
},
"arguments": []
}
}
],
"sourceType": "script",
"tokens": [
{
"type": "Punctuator",
"value": "(",
"range": [
0,
1
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
}
},
{
"type": "Identifier",
"value": "async",
"range": [
1,
6
],
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
}
}
},
{
"type": "Keyword",
"value": "function",
"range": [
7,
15
],
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 15
}
}
},
{
"type": "Identifier",
"value": "test",
"range": [
16,
20
],
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 20
}
}
},
{
"type": "Punctuator",
"value": "(",
"range": [
20,
21
],
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
}
}
},
{
"type": "Punctuator",
"value": ")",
"range": [
21,
22
],
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 22
}
}
},
{
"type": "Punctuator",
"value": "{",
"range": [
23,
24
],
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 24
}
}
},
{
"type": "Punctuator",
"value": "}",
"range": [
25,
26
],
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
}
}
},
{
"type": "Punctuator",
"value": ")",
"range": [
26,
27
],
"loc": {
"start": {
"line": 2,
"column": 1
},
"end": {
"line": 2,
"column": 2
}
}
},
{
"type": "Punctuator",
"value": "(",
"range": [
27,
28
],
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
}
}
},
{
"type": "Punctuator",
"value": ")",
"range": [
28,
29
],
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
}
}
},
{
"type": "Punctuator",
"value": ";",
"range": [
29,
30
],
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
}
}
}
]
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(async function test() {
})();

0 comments on commit a294afa

Please sign in to comment.