Skip to content

Commit b936e91

Browse files
committed
Support JS import attributes (previously import assertions)
1 parent d54ab64 commit b936e91

File tree

3 files changed

+221
-219
lines changed

3 files changed

+221
-219
lines changed

javascript/extractor/src/com/semmle/jcorn/Parser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3563,7 +3563,9 @@ protected Statement parseImport(Position startLoc) {
35633563
protected Expression parseImportOrExportAssertionAndSemicolon() {
35643564
Expression result = null;
35653565
if (!this.eagerlyTrySemicolon()) {
3566-
this.expectContextual("assert");
3566+
if (!this.eatContextual("assert")) {
3567+
this.expect(TokenType._with);
3568+
}
35673569
result = this.parseObj(false, null);
35683570
this.semicolon();
35693571
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import "module" assert { type: "json" };
2-
import * as v1 from "module" assert { type: "json" };
3-
import { v2 } from "module" assert { type: "json" };
4-
import v3 from "module" assert { type: "json" };
1+
import "module" with { type: "json" };
2+
import * as v1 from "module" with { type: "json" };
3+
import { v2 } from "module" with { type: "json" };
4+
import v3 from "module" with { type: "json" };
55

6-
export { v4 } from "module" assert { type: "json" };
7-
export * from "module" assert { type: "json" };
8-
export * as v5 from "module" assert { type: "json" };
6+
export { v4 } from "module" with { type: "json" };
7+
export * from "module" with { type: "json" };
8+
export * as v5 from "module" with { type: "json" };
99

10-
const v6 = import("module", { assert: { type: "json" } });
10+
const v6 = import("module", { with: { type: "json" } });
1111

1212
import "module" // missing semicolon
1313
assert({type: "json"}); // function call, not import assertion

0 commit comments

Comments
 (0)