Skip to content

Commit

Permalink
allow line termination prior to the with keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Jul 1, 2023
1 parent e4c7a6e commit e2af355
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8270,7 +8270,7 @@ namespace Parser {
const moduleSpecifier = parseModuleSpecifier();

let attributes: ImportAttributes | undefined;
if (token() === SyntaxKind.WithKeyword && !scanner.hasPrecedingLineBreak()) {
if (token() === SyntaxKind.WithKeyword) {
attributes = parseImportAttributes();
}

Expand Down Expand Up @@ -8536,7 +8536,7 @@ namespace Parser {
moduleSpecifier = parseModuleSpecifier();
}
}
if (moduleSpecifier && token() === SyntaxKind.WithKeyword && !scanner.hasPrecedingLineBreak()) {
if (moduleSpecifier && token() === SyntaxKind.WithKeyword) {
attributes = parseImportAttributes();
}
parseSemicolon();
Expand Down
22 changes: 22 additions & 0 deletions tests/baselines/reference/importAttributes8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//// [tests/cases/conformance/importAttributes/importAttributes8.ts] ////

//// [a.ts]
export default {
a: "a",
b: "b",
1: "1",
}

//// [b.ts]
import a from "./a"
with { a: "a", "b": "b", 1: "1" }; // ok


//// [a.js]
export default {
a: "a",
b: "b",
1: "1",
};
//// [b.js]
export {};
20 changes: 20 additions & 0 deletions tests/baselines/reference/importAttributes8.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//// [tests/cases/conformance/importAttributes/importAttributes8.ts] ////

=== /a.ts ===
export default {
a: "a",
>a : Symbol(a, Decl(a.ts, 0, 16))

b: "b",
>b : Symbol(b, Decl(a.ts, 1, 11))

1: "1",
>1 : Symbol(1, Decl(a.ts, 2, 11))
}

=== /b.ts ===
import a from "./a"
>a : Symbol(a, Decl(b.ts, 0, 6))

with { a: "a", "b": "b", 1: "1" }; // ok

26 changes: 26 additions & 0 deletions tests/baselines/reference/importAttributes8.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//// [tests/cases/conformance/importAttributes/importAttributes8.ts] ////

=== /a.ts ===
export default {
>{ a: "a", b: "b", 1: "1",} : { a: string; b: string; 1: string; }

a: "a",
>a : string
>"a" : "a"

b: "b",
>b : string
>"b" : "b"

1: "1",
>1 : string
>"1" : "1"
}

=== /b.ts ===
import a from "./a"
>a : { a: string; b: string; 1: string; }

with { a: "a", "b": "b", 1: "1" }; // ok
>a : error

13 changes: 13 additions & 0 deletions tests/cases/conformance/importAttributes/importAttributes8.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @module: esnext
// @lib: es2015

// @filename: /a.ts
export default {
a: "a",
b: "b",
1: "1",
}

// @filename: /b.ts
import a from "./a"
with { a: "a", "b": "b", 1: "1" }; // ok

0 comments on commit e2af355

Please sign in to comment.