@@ -176,7 +176,8 @@ public class TypeScriptASTConverter {
176
176
private static final Pattern EXPORT_DECL_START =
177
177
Pattern .compile ("^export" + "(" + WHITESPACE_CHAR + "+default)?" + WHITESPACE_CHAR + "+" );
178
178
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 + "+" );
180
181
private static final Pattern WHITESPACE_END_PAREN =
181
182
Pattern .compile ("^" + WHITESPACE_CHAR + "*\\ )" );
182
183
@@ -342,10 +343,10 @@ private Node convertNodeUntyped(JsonObject node, String defaultKind) throws Pars
342
343
return convertArrowFunction (node , loc );
343
344
case "AsExpression" :
344
345
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 );
349
350
case "SatisfiesExpression" :
350
351
return convertSatisfiesExpression (node , loc );
351
352
case "AwaitExpression" :
@@ -2297,20 +2298,20 @@ private Node convertTypeAssertionExpression(JsonObject node, SourceLocation loc)
2297
2298
return new TypeAssertion (loc , convertChild (node , "expression" ), type , false );
2298
2299
}
2299
2300
2300
- private Node convertAssertClause (JsonObject node , SourceLocation loc ) throws ParseError {
2301
+ private Node convertImportAttributes (JsonObject node , SourceLocation loc ) throws ParseError {
2301
2302
List <Property > properties = new ArrayList <>();
2302
2303
for (INode child : convertChildren (node , "elements" )) {
2303
2304
properties .add ((Property ) child );
2304
2305
}
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 ());
2307
2308
if (m .find ()) {
2308
2309
advance (loc , m .group (0 ));
2309
2310
}
2310
2311
return new ObjectExpression (loc , properties );
2311
2312
}
2312
2313
2313
- private Node convertAssertEntry (JsonObject node , SourceLocation loc ) throws ParseError {
2314
+ private Node convertImportAttribute (JsonObject node , SourceLocation loc ) throws ParseError {
2314
2315
return new Property (
2315
2316
loc , convertChild (node , "key" ), convertChild (node , "value" ), "init" , false , false );
2316
2317
}
0 commit comments