Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions testdata/baselines/reference/compiler/awaitObjectLiteral.js
Original file line number Diff line number Diff line change
@@ -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" };
14 changes: 14 additions & 0 deletions testdata/baselines/reference/compiler/awaitObjectLiteral.symbols
Original file line number Diff line number Diff line change
@@ -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))

21 changes: 21 additions & 0 deletions testdata/baselines/reference/compiler/awaitObjectLiteral.types
Original file line number Diff line number Diff line change
@@ -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"

Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<T>(asyncIterable!: AsyncIterable<T>): Promise<T[]> {
~~~~~~~~~~~~~~
!!! error TS7010: 'arrayFromAsync', which lacks return-type annotation, implicitly has an 'any' return type.
Expand Down Expand Up @@ -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.
~
Expand Down Expand Up @@ -121,6 +117,4 @@ reachabilityChecksNoCrash1.ts(7,1): error TS1128: Declaration or statement expec
}
~
!!! error TS1109: Expression expected.
~
!!! error TS1128: Declaration or statement expected.

Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,12 @@
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<T>(asyncIterable!: AsyncIterable<T>): Promise<T[]> {
~~~~~~~~~~~~~~
!!! 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.
}
~~~~~
-!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '{ const: any; for: any; of: any; asyncIterable: any; out: any; "": any; }'.
+!!! 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.

~
9 changes: 9 additions & 0 deletions testdata/tests/cases/compiler/awaitObjectLiteral.ts
Original file line number Diff line number Diff line change
@@ -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" }
Loading