Skip to content

Commit e2af355

Browse files
committed
allow line termination prior to the with keyword
1 parent e4c7a6e commit e2af355

File tree

5 files changed

+83
-2
lines changed

5 files changed

+83
-2
lines changed

src/compiler/parser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8270,7 +8270,7 @@ namespace Parser {
82708270
const moduleSpecifier = parseModuleSpecifier();
82718271

82728272
let attributes: ImportAttributes | undefined;
8273-
if (token() === SyntaxKind.WithKeyword && !scanner.hasPrecedingLineBreak()) {
8273+
if (token() === SyntaxKind.WithKeyword) {
82748274
attributes = parseImportAttributes();
82758275
}
82768276

@@ -8536,7 +8536,7 @@ namespace Parser {
85368536
moduleSpecifier = parseModuleSpecifier();
85378537
}
85388538
}
8539-
if (moduleSpecifier && token() === SyntaxKind.WithKeyword && !scanner.hasPrecedingLineBreak()) {
8539+
if (moduleSpecifier && token() === SyntaxKind.WithKeyword) {
85408540
attributes = parseImportAttributes();
85418541
}
85428542
parseSemicolon();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//// [tests/cases/conformance/importAttributes/importAttributes8.ts] ////
2+
3+
//// [a.ts]
4+
export default {
5+
a: "a",
6+
b: "b",
7+
1: "1",
8+
}
9+
10+
//// [b.ts]
11+
import a from "./a"
12+
with { a: "a", "b": "b", 1: "1" }; // ok
13+
14+
15+
//// [a.js]
16+
export default {
17+
a: "a",
18+
b: "b",
19+
1: "1",
20+
};
21+
//// [b.js]
22+
export {};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//// [tests/cases/conformance/importAttributes/importAttributes8.ts] ////
2+
3+
=== /a.ts ===
4+
export default {
5+
a: "a",
6+
>a : Symbol(a, Decl(a.ts, 0, 16))
7+
8+
b: "b",
9+
>b : Symbol(b, Decl(a.ts, 1, 11))
10+
11+
1: "1",
12+
>1 : Symbol(1, Decl(a.ts, 2, 11))
13+
}
14+
15+
=== /b.ts ===
16+
import a from "./a"
17+
>a : Symbol(a, Decl(b.ts, 0, 6))
18+
19+
with { a: "a", "b": "b", 1: "1" }; // ok
20+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//// [tests/cases/conformance/importAttributes/importAttributes8.ts] ////
2+
3+
=== /a.ts ===
4+
export default {
5+
>{ a: "a", b: "b", 1: "1",} : { a: string; b: string; 1: string; }
6+
7+
a: "a",
8+
>a : string
9+
>"a" : "a"
10+
11+
b: "b",
12+
>b : string
13+
>"b" : "b"
14+
15+
1: "1",
16+
>1 : string
17+
>"1" : "1"
18+
}
19+
20+
=== /b.ts ===
21+
import a from "./a"
22+
>a : { a: string; b: string; 1: string; }
23+
24+
with { a: "a", "b": "b", 1: "1" }; // ok
25+
>a : error
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @module: esnext
2+
// @lib: es2015
3+
4+
// @filename: /a.ts
5+
export default {
6+
a: "a",
7+
b: "b",
8+
1: "1",
9+
}
10+
11+
// @filename: /b.ts
12+
import a from "./a"
13+
with { a: "a", "b": "b", 1: "1" }; // ok

0 commit comments

Comments
 (0)