@@ -176,7 +176,8 @@ public class TypeScriptASTConverter {
176176 private static final Pattern EXPORT_DECL_START =
177177 Pattern .compile ("^export" + "(" + WHITESPACE_CHAR + "+default)?" + WHITESPACE_CHAR + "+" );
178178 private static final Pattern TYPEOF_START = Pattern .compile ("^typeof" + WHITESPACE_CHAR + "+" );
179- private static final Pattern ASSERT_START = Pattern .compile ("^assert" + WHITESPACE_CHAR + "+" );
179+ private static final Pattern IMPORT_ATTRIBUTE_START =
180+ Pattern .compile ("^(assert|with)" + WHITESPACE_CHAR + "+" );
180181 private static final Pattern WHITESPACE_END_PAREN =
181182 Pattern .compile ("^" + WHITESPACE_CHAR + "*\\ )" );
182183
@@ -342,10 +343,10 @@ private Node convertNodeUntyped(JsonObject node, String defaultKind) throws Pars
342343 return convertArrowFunction (node , loc );
343344 case "AsExpression" :
344345 return convertTypeAssertionExpression (node , loc );
345- case "AssertClause " :
346- return convertAssertClause (node , loc );
347- case "AssertEntry " :
348- return convertAssertEntry (node , loc );
346+ case "ImportAttributes " :
347+ return convertImportAttributes (node , loc );
348+ case "ImportAttribute " :
349+ return convertImportAttribute (node , loc );
349350 case "SatisfiesExpression" :
350351 return convertSatisfiesExpression (node , loc );
351352 case "AwaitExpression" :
@@ -2297,20 +2298,20 @@ private Node convertTypeAssertionExpression(JsonObject node, SourceLocation loc)
22972298 return new TypeAssertion (loc , convertChild (node , "expression" ), type , false );
22982299 }
22992300
2300- private Node convertAssertClause (JsonObject node , SourceLocation loc ) throws ParseError {
2301+ private Node convertImportAttributes (JsonObject node , SourceLocation loc ) throws ParseError {
23012302 List <Property > properties = new ArrayList <>();
23022303 for (INode child : convertChildren (node , "elements" )) {
23032304 properties .add ((Property ) child );
23042305 }
2305- // Adjust location to skip over the `assert` keyword.
2306- Matcher m = ASSERT_START .matcher (loc .getSource ());
2306+ // Adjust location to skip over the `with` or ` assert` keyword.
2307+ Matcher m = IMPORT_ATTRIBUTE_START .matcher (loc .getSource ());
23072308 if (m .find ()) {
23082309 advance (loc , m .group (0 ));
23092310 }
23102311 return new ObjectExpression (loc , properties );
23112312 }
23122313
2313- private Node convertAssertEntry (JsonObject node , SourceLocation loc ) throws ParseError {
2314+ private Node convertImportAttribute (JsonObject node , SourceLocation loc ) throws ParseError {
23142315 return new Property (
23152316 loc , convertChild (node , "key" ), convertChild (node , "value" ), "init" , false , false );
23162317 }
0 commit comments