diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 3c9ecee716..60e0b3efb9 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -2887,6 +2887,7 @@ func (p *Parser) parseImportType() *ast.Node { } p.parseExpected(ast.KindColonToken) attributes = p.parseImportAttributes(currentToken, true /*skipKeyword*/) + p.parseOptional(ast.KindCommaToken) if !p.parseExpected(ast.KindCloseBraceToken) { if len(p.diagnostics) != 0 { lastDiagnostic := p.diagnostics[len(p.diagnostics)-1] diff --git a/testdata/baselines/reference/submodule/conformance/importAttributes10.errors.txt b/testdata/baselines/reference/submodule/conformance/importAttributes10.errors.txt index 922e383c71..38e981882e 100644 --- a/testdata/baselines/reference/submodule/conformance/importAttributes10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importAttributes10.errors.txt @@ -1,11 +1,7 @@ b.ts(7,35): error TS2732: Cannot find module './a.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. -b.ts(10,4): error TS1005: '}' expected. -b.ts(11,1): error TS1128: Declaration or statement expected. -b.ts(11,2): error TS1128: Declaration or statement expected. b.ts(13,35): error TS2732: Cannot find module './a.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. b.ts(19,35): error TS2732: Cannot find module './a.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. -b.ts(22,4): error TS1005: '}' expected. -b.ts(22,5): error TS1128: Declaration or statement expected. +b.ts(22,5): error TS1005: '}' expected. b.ts(23,1): error TS1128: Declaration or statement expected. b.ts(23,2): error TS1128: Declaration or statement expected. b.ts(25,35): error TS2732: Cannot find module './a.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. @@ -15,7 +11,7 @@ b.ts(27,18): error TS1478: Identifier or string literal expected. ==== a.json (0 errors) ==== { "key": "value" } -==== b.ts (12 errors) ==== +==== b.ts (8 errors) ==== declare global { interface ImportAttributes { type: "json" @@ -28,14 +24,7 @@ b.ts(27,18): error TS1478: Identifier or string literal expected. with: { type: "json" }, - ~ -!!! error TS1005: '}' expected. -!!! related TS1007 b.ts:7:47: The parser expected to find a '}' to match the '{' token here. }); - ~ -!!! error TS1128: Declaration or statement expected. - ~ -!!! error TS1128: Declaration or statement expected. export type Test2 = typeof import("./a.json", { ~~~~~~~~~~ @@ -51,11 +40,9 @@ b.ts(27,18): error TS1478: Identifier or string literal expected. with: { type: "json" },, - ~ + ~ !!! error TS1005: '}' expected. !!! related TS1007 b.ts:19:47: The parser expected to find a '}' to match the '{' token here. - ~ -!!! error TS1128: Declaration or statement expected. }); ~ !!! error TS1128: Declaration or statement expected. diff --git a/testdata/baselines/reference/submodule/conformance/importAttributes10.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/importAttributes10.errors.txt.diff index e646734e03..d0c089bb50 100644 --- a/testdata/baselines/reference/submodule/conformance/importAttributes10.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/importAttributes10.errors.txt.diff @@ -1,15 +1,10 @@ --- old.importAttributes10.errors.txt +++ new.importAttributes10.errors.txt @@= skipped -0, +0 lines =@@ --b.ts(22,5): error TS1005: '}' expected. +b.ts(7,35): error TS2732: Cannot find module './a.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. -+b.ts(10,4): error TS1005: '}' expected. -+b.ts(11,1): error TS1128: Declaration or statement expected. -+b.ts(11,2): error TS1128: Declaration or statement expected. +b.ts(13,35): error TS2732: Cannot find module './a.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. +b.ts(19,35): error TS2732: Cannot find module './a.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. -+b.ts(22,4): error TS1005: '}' expected. -+b.ts(22,5): error TS1128: Declaration or statement expected. + b.ts(22,5): error TS1005: '}' expected. b.ts(23,1): error TS1128: Declaration or statement expected. b.ts(23,2): error TS1128: Declaration or statement expected. +b.ts(25,35): error TS2732: Cannot find module './a.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. @@ -20,11 +15,11 @@ { "key": "value" } -==== b.ts (4 errors) ==== -+==== b.ts (12 errors) ==== ++==== b.ts (8 errors) ==== declare global { interface ImportAttributes { type: "json" -@@= skipped -14, +22 lines =@@ +@@= skipped -14, +18 lines =@@ } export type Test1 = typeof import("./a.json", { @@ -33,14 +28,7 @@ with: { type: "json" }, -+ ~ -+!!! error TS1005: '}' expected. -+!!! related TS1007 b.ts:7:47: The parser expected to find a '}' to match the '{' token here. }); -+ ~ -+!!! error TS1128: Declaration or statement expected. -+ ~ -+!!! error TS1128: Declaration or statement expected. export type Test2 = typeof import("./a.json", { + ~~~~~~~~~~ @@ -56,16 +44,7 @@ with: { type: "json" },, -- ~ -+ ~ - !!! error TS1005: '}' expected. - !!! related TS1007 b.ts:19:47: The parser expected to find a '}' to match the '{' token here. -+ ~ -+!!! error TS1128: Declaration or statement expected. - }); - ~ - !!! error TS1128: Declaration or statement expected. -@@= skipped -25, +40 lines =@@ +@@= skipped -25, +31 lines =@@ !!! error TS1128: Declaration or statement expected. export type Test4 = typeof import("./a.json", { diff --git a/testdata/baselines/reference/submodule/conformance/importAttributes10.js b/testdata/baselines/reference/submodule/conformance/importAttributes10.js index 8413c8b3b1..85768b224f 100644 --- a/testdata/baselines/reference/submodule/conformance/importAttributes10.js +++ b/testdata/baselines/reference/submodule/conformance/importAttributes10.js @@ -39,4 +39,3 @@ export type Test4 = typeof import("./a.json", { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); ; -; diff --git a/testdata/baselines/reference/submodule/conformance/importAttributes10.js.diff b/testdata/baselines/reference/submodule/conformance/importAttributes10.js.diff deleted file mode 100644 index f7c9d71ea3..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importAttributes10.js.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.importAttributes10.js -+++ new.importAttributes10.js -@@= skipped -38, +38 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - ; -+; \ No newline at end of file