TS: fix extraction of binding pattern with default

This commit is contained in:
Asger F
2018-12-11 17:36:22 +00:00
parent 9707b34124
commit aa04e9c77f
4 changed files with 12 additions and 1 deletions

View File

@@ -1612,7 +1612,7 @@ public class TypeScriptASTConverter {
if (hasChild(element, "dotDotDotToken")) {
propVal = new RestElement(eltLoc, propKey);
} else if (hasChild(element, "initializer")) {
propVal = new AssignmentPattern(eltLoc, "=", propKey, convertChild(element, "initializer"));
propVal = new AssignmentPattern(eltLoc, "=", convertChild(element, "name"), convertChild(element, "initializer"));
} else {
propVal = convertChild(element, "name");
}

View File

@@ -0,0 +1,3 @@
| tst.tsx:1:10:1:10 | f |
| tst.tsx:1:12:1:12 | o |
| tst.tsx:2:14:2:14 | v |

View File

@@ -0,0 +1,4 @@
import javascript
from VarDecl decl
select decl

View File

@@ -0,0 +1,4 @@
function f(o) {
const { p: v = [] } = o;
return v;
}