diff --git a/internal/parser/parser.go b/internal/parser/parser.go index f0ccfc3f9ea..af0dbcc1669 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -532,7 +532,7 @@ func (p *Parser) reparseTopLevelAwait(sourceFile *ast.SourceFile) *ast.Node { }) var diagnosticEnd int if diagnosticStart >= 0 { - diagnosticEnd = core.FindIndex(savedParseDiagnostics[:diagnosticStart], func(diagnostic *ast.Diagnostic) bool { + diagnosticEnd = core.FindIndex(savedParseDiagnostics[diagnosticStart:], func(diagnostic *ast.Diagnostic) bool { return diagnostic.Pos() >= nextStatement.Pos() }) } else { diff --git a/testdata/baselines/reference/compiler/awaitObjectLiteral.js b/testdata/baselines/reference/compiler/awaitObjectLiteral.js new file mode 100644 index 00000000000..4a995580430 --- /dev/null +++ b/testdata/baselines/reference/compiler/awaitObjectLiteral.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/awaitObjectLiteral.ts] //// + +//// [fileA.ts] +export {} +const foo = await { bar: 42 } + +//// [fileB.ts] +export const baz = await { x: 1, y: "hello" } + + +//// [fileA.js] +const foo = await { bar: 42 }; +export {}; +//// [fileB.js] +export const baz = await { x: 1, y: "hello" }; diff --git a/testdata/baselines/reference/compiler/awaitObjectLiteral.symbols b/testdata/baselines/reference/compiler/awaitObjectLiteral.symbols new file mode 100644 index 00000000000..c2e84e4befd --- /dev/null +++ b/testdata/baselines/reference/compiler/awaitObjectLiteral.symbols @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/awaitObjectLiteral.ts] //// + +=== fileA.ts === +export {} +const foo = await { bar: 42 } +>foo : Symbol(foo, Decl(fileA.ts, 1, 5)) +>bar : Symbol(bar, Decl(fileA.ts, 1, 19)) + +=== fileB.ts === +export const baz = await { x: 1, y: "hello" } +>baz : Symbol(baz, Decl(fileB.ts, 0, 12)) +>x : Symbol(x, Decl(fileB.ts, 0, 26)) +>y : Symbol(y, Decl(fileB.ts, 0, 32)) + diff --git a/testdata/baselines/reference/compiler/awaitObjectLiteral.types b/testdata/baselines/reference/compiler/awaitObjectLiteral.types new file mode 100644 index 00000000000..a25e8f32110 --- /dev/null +++ b/testdata/baselines/reference/compiler/awaitObjectLiteral.types @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/awaitObjectLiteral.ts] //// + +=== fileA.ts === +export {} +const foo = await { bar: 42 } +>foo : { bar: number; } +>await { bar: 42 } : { bar: number; } +>{ bar: 42 } : { bar: number; } +>bar : number +>42 : 42 + +=== fileB.ts === +export const baz = await { x: 1, y: "hello" } +>baz : { x: number; y: string; } +>await { x: 1, y: "hello" } : { x: number; y: string; } +>{ x: 1, y: "hello" } : { x: number; y: string; } +>x : number +>1 : 1 +>y : string +>"hello" : "hello" + diff --git a/testdata/baselines/reference/submodule/compiler/reachabilityChecksNoCrash1.errors.txt b/testdata/baselines/reference/submodule/compiler/reachabilityChecksNoCrash1.errors.txt index 721d50fa3a9..fa08b6ff74c 100644 --- a/testdata/baselines/reference/submodule/compiler/reachabilityChecksNoCrash1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/reachabilityChecksNoCrash1.errors.txt @@ -20,7 +20,6 @@ reachabilityChecksNoCrash1.ts(2,11): error TS2304: Cannot find name 'out'. reachabilityChecksNoCrash1.ts(2,19): error TS1005: ',' expected. reachabilityChecksNoCrash1.ts(3,9): error TS1005: ':' expected. reachabilityChecksNoCrash1.ts(3,16): error TS1109: Expression expected. -reachabilityChecksNoCrash1.ts(3,16): error TS1135: Argument expression expected. reachabilityChecksNoCrash1.ts(3,22): error TS1005: ':' expected. reachabilityChecksNoCrash1.ts(3,22): error TS2304: Cannot find name 'v'. reachabilityChecksNoCrash1.ts(3,24): error TS1005: ',' expected. @@ -34,10 +33,9 @@ reachabilityChecksNoCrash1.ts(4,12): error TS1005: ',' expected. reachabilityChecksNoCrash1.ts(4,24): error TS2304: Cannot find name 'v'. reachabilityChecksNoCrash1.ts(4,26): error TS1005: ',' expected. reachabilityChecksNoCrash1.ts(7,1): error TS1109: Expression expected. -reachabilityChecksNoCrash1.ts(7,1): error TS1128: Declaration or statement expected. -==== reachabilityChecksNoCrash1.ts (37 errors) ==== +==== reachabilityChecksNoCrash1.ts (35 errors) ==== export async function arrayFromAsync(asyncIterable!: AsyncIterable): Promise { ~~~~~~~~~~~~~~ !!! error TS7010: 'arrayFromAsync', which lacks return-type annotation, implicitly has an 'any' return type. @@ -86,8 +84,6 @@ reachabilityChecksNoCrash1.ts(7,1): error TS1128: Declaration or statement expec !!! error TS1005: ':' expected. ~~~~~ !!! error TS1109: Expression expected. - ~~~~~ -!!! error TS1135: Argument expression expected. ~ !!! error TS1005: ':' expected. ~ @@ -121,6 +117,4 @@ reachabilityChecksNoCrash1.ts(7,1): error TS1128: Declaration or statement expec } ~ !!! error TS1109: Expression expected. - ~ -!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/reachabilityChecksNoCrash1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/reachabilityChecksNoCrash1.errors.txt.diff index ff9b9d54b5a..c014d58694e 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/reachabilityChecksNoCrash1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/reachabilityChecksNoCrash1.errors.txt.diff @@ -9,38 +9,7 @@ reachabilityChecksNoCrash1.ts(1,84): error TS2304: Cannot find name 'T'. reachabilityChecksNoCrash1.ts(1,86): error TS1011: An element access expression should take an argument. reachabilityChecksNoCrash1.ts(2,11): error TS1005: ':' expected. -@@= skipped -8, +8 lines =@@ - reachabilityChecksNoCrash1.ts(2,19): error TS1005: ',' expected. - reachabilityChecksNoCrash1.ts(3,9): error TS1005: ':' expected. - reachabilityChecksNoCrash1.ts(3,16): error TS1109: Expression expected. -+reachabilityChecksNoCrash1.ts(3,16): error TS1135: Argument expression expected. - reachabilityChecksNoCrash1.ts(3,22): error TS1005: ':' expected. - reachabilityChecksNoCrash1.ts(3,22): error TS2304: Cannot find name 'v'. - reachabilityChecksNoCrash1.ts(3,24): error TS1005: ',' expected. -@@= skipped -13, +14 lines =@@ - reachabilityChecksNoCrash1.ts(4,24): error TS2304: Cannot find name 'v'. - reachabilityChecksNoCrash1.ts(4,26): error TS1005: ',' expected. - reachabilityChecksNoCrash1.ts(7,1): error TS1109: Expression expected. -- -- --==== reachabilityChecksNoCrash1.ts (35 errors) ==== -+reachabilityChecksNoCrash1.ts(7,1): error TS1128: Declaration or statement expected. -+ -+ -+==== reachabilityChecksNoCrash1.ts (37 errors) ==== - export async function arrayFromAsync(asyncIterable!: AsyncIterable): Promise { - ~~~~~~~~~~~~~~ - !!! error TS7010: 'arrayFromAsync', which lacks return-type annotation, implicitly has an 'any' return type. -@@= skipped -51, +52 lines =@@ - !!! error TS1005: ':' expected. - ~~~~~ - !!! error TS1109: Expression expected. -+ ~~~~~ -+!!! error TS1135: Argument expression expected. - ~ - !!! error TS1005: ':' expected. - ~ -@@= skipped -28, +30 lines =@@ +@@= skipped -100, +100 lines =@@ !!! error TS1005: ',' expected. } ~~~~~ @@ -48,8 +17,4 @@ +!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '{ const: never[]; for: any; of: any; asyncIterable: any; out: any; "": any; }'. return out; } - ~ - !!! error TS1109: Expression expected. -+ ~ -+!!! error TS1128: Declaration or statement expected. - \ No newline at end of file + ~ \ No newline at end of file diff --git a/testdata/tests/cases/compiler/awaitObjectLiteral.ts b/testdata/tests/cases/compiler/awaitObjectLiteral.ts new file mode 100644 index 00000000000..d63cf68d1d2 --- /dev/null +++ b/testdata/tests/cases/compiler/awaitObjectLiteral.ts @@ -0,0 +1,9 @@ +// @target: esnext +// @module: esnext + +// @filename: fileA.ts +export {} +const foo = await { bar: 42 } + +// @filename: fileB.ts +export const baz = await { x: 1, y: "hello" }