@@ -1203,27 +1203,35 @@ private Node convertExportDeclaration(JsonObject node, SourceLocation loc) throw
12031203 Literal source = tryConvertChild (node , "moduleSpecifier" , Literal .class );
12041204 Expression attributes = convertChild (node , "attributes" );
12051205 if (hasChild (node , "exportClause" )) {
1206+ JsonElement exportClauseNode = node .get ("exportClause" );
12061207 boolean hasTypeKeyword = node .get ("isTypeOnly" ).getAsBoolean ();
1208+ boolean isNamespaceExportNode = hasKind (exportClauseNode , "NamespaceExport" );
12071209 List <ExportSpecifier > specifiers =
1208- hasKind ( node . get ( "exportClause" ), "NamespaceExport" )
1210+ isNamespaceExportNode
12091211 ? Collections .singletonList (convertChild (node , "exportClause" ))
1210- : convertChildren (node . get ( "exportClause" ) .getAsJsonObject (), "elements" );
1212+ : convertChildren (exportClauseNode .getAsJsonObject (), "elements" );
12111213 return new ExportNamedDeclaration (loc , null , specifiers , source , attributes , hasTypeKeyword );
12121214 } else {
12131215 return new ExportAllDeclaration (loc , source , attributes );
12141216 }
12151217 }
12161218
12171219 private Node convertExportSpecifier (JsonObject node , SourceLocation loc ) throws ParseError {
1220+ Identifier local = convertChild (node , hasChild (node , "propertyName" ) ? "propertyName" : "name" );
1221+ JsonObject exportedToken = node .get ("name" ).getAsJsonObject ();
1222+ Identifier exported = convertNodeAsIdentifier (exportedToken );
1223+
12181224 return new ExportSpecifier (
12191225 loc ,
1220- convertChild ( node , hasChild ( node , "propertyName" ) ? "propertyName" : "name" ) ,
1221- convertChild ( node , "name" ) );
1226+ local ,
1227+ exported );
12221228 }
12231229
12241230 private Node convertNamespaceExport (JsonObject node , SourceLocation loc ) throws ParseError {
12251231 // Convert the "* as ns" from an export declaration.
1226- return new ExportNamespaceSpecifier (loc , convertChild (node , "name" ));
1232+ JsonObject exportedNamespaceToken = node .get ("name" ).getAsJsonObject ();
1233+ Identifier exportedNamespaceIdentifier = convertNodeAsIdentifier (exportedNamespaceToken );
1234+ return new ExportNamespaceSpecifier (loc , exportedNamespaceIdentifier );
12271235 }
12281236
12291237 private Node convertExpressionStatement (JsonObject node , SourceLocation loc ) throws ParseError {
@@ -1431,7 +1439,8 @@ private Node convertImportKeyword(SourceLocation loc) {
14311439
14321440 private Node convertImportSpecifier (JsonObject node , SourceLocation loc ) throws ParseError {
14331441 boolean hasImported = hasChild (node , "propertyName" );
1434- Identifier imported = convertChild (node , hasImported ? "propertyName" : "name" );
1442+ JsonObject importedToken = node .get (hasImported ? "propertyName" : "name" ).getAsJsonObject ();
1443+ Identifier imported = convertNodeAsIdentifier (importedToken );
14351444 Identifier local = convertChild (node , "name" );
14361445 boolean isTypeOnly = node .get ("isTypeOnly" ).getAsBoolean () == true ;
14371446 return new ImportSpecifier (loc , imported , local , isTypeOnly );
0 commit comments