From 3e9aa22867023ef2288953fb7e1e99b74a8a935a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 3 Aug 2026 19:03:13 +0000 Subject: [PATCH 1/9] Add namespace await context regression test Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- ...ceExportedClassComputedProperty.errors.txt | 14 +++++++++++ ...nNamespaceExportedClassComputedProperty.js | 23 +++++++++++++++++++ ...spaceExportedClassComputedProperty.symbols | 21 +++++++++++++++++ ...mespaceExportedClassComputedProperty.types | 23 +++++++++++++++++++ ...nNamespaceExportedClassComputedProperty.ts | 9 ++++++++ 5 files changed, 90 insertions(+) create mode 100644 testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt create mode 100644 testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js create mode 100644 testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols create mode 100644 testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types create mode 100644 testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt new file mode 100644 index 00000000000..623901739c7 --- /dev/null +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt @@ -0,0 +1,14 @@ +awaitInNamespaceExportedClassComputedProperty.ts(3,16): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. + + +==== awaitInNamespaceExportedClassComputedProperty.ts (1 errors) ==== + declare const x: string; + namespace N { + class A { [await x]() {} } + ~~~~~ +!!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:3:15: Did you mean to mark this function as 'async'? + export class B { [await x]() {} } + } + export {}; + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js new file mode 100644 index 00000000000..3d03e189e0f --- /dev/null +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts] //// + +//// [awaitInNamespaceExportedClassComputedProperty.ts] +declare const x: string; +namespace N { + class A { [await x]() {} } + export class B { [await x]() {} } +} +export {}; + + +//// [awaitInNamespaceExportedClassComputedProperty.js] +var N; +(function (N) { + class A { + [await x]() { } + } + class B { + [await x]() { } + } + N.B = B; +})(N || (N = {})); +export {}; diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols new file mode 100644 index 00000000000..4236210b95c --- /dev/null +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts] //// + +=== awaitInNamespaceExportedClassComputedProperty.ts === +declare const x: string; +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) + +namespace N { +>N : Symbol(N, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 24)) + + class A { [await x]() {} } +>A : Symbol(A, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 1, 13)) +>[await x] : Symbol(A[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 2, 13)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) + + export class B { [await x]() {} } +>B : Symbol(B, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 2, 30)) +>[await x] : Symbol(B[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 3, 20)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) +} +export {}; + diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types new file mode 100644 index 00000000000..b00adea52b9 --- /dev/null +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts] //// + +=== awaitInNamespaceExportedClassComputedProperty.ts === +declare const x: string; +>x : string + +namespace N { +>N : typeof N + + class A { [await x]() {} } +>A : A +>[await x] : () => void +>await x : string +>x : string + + export class B { [await x]() {} } +>B : B +>[await x] : () => void +>await x : string +>x : string +} +export {}; + diff --git a/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts b/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts new file mode 100644 index 00000000000..1c2701db217 --- /dev/null +++ b/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts @@ -0,0 +1,9 @@ +// @target: esnext +// @module: esnext + +declare const x: string; +namespace N { + class A { [await x]() {} } + export class B { [await x]() {} } +} +export {}; From eef81c0654eb24498688107ebf1902e46e1b39bc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 3 Aug 2026 19:05:20 +0000 Subject: [PATCH 2/9] Limit exported class await context to top level Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- internal/parser/parser.go | 2 +- ...waitInNamespaceExportedClassComputedProperty.errors.txt | 7 ++++++- .../awaitInNamespaceExportedClassComputedProperty.js | 5 ++++- .../awaitInNamespaceExportedClassComputedProperty.symbols | 5 +++++ .../awaitInNamespaceExportedClassComputedProperty.types | 6 ++++++ .../awaitInNamespaceExportedClassComputedProperty.ts | 1 + 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 47c17b74476..fcb177c6bd5 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -1748,7 +1748,7 @@ func (p *Parser) parseClassDeclarationOrExpression(pos int, jsdoc jsdocScannerIn // We don't parse the name here in await context, instead we will report a grammar error in the checker. name := p.parseNameOfClassDeclarationOrExpression() typeParameters := p.parseTypeParameters() - if modifiers != nil && core.Some(modifiers.Nodes, isExportModifier) { + if modifiers != nil && core.Some(modifiers.Nodes, isExportModifier) && p.parsingContexts == 1<[await x] : Symbol(B[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 3, 20)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } +export class C { [await x]() {} } +>C : Symbol(C, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 4, 1)) +>[await x] : Symbol(C[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 5, 16)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) + export {}; diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types index b00adea52b9..5969f54087d 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types @@ -19,5 +19,11 @@ namespace N { >await x : string >x : string } +export class C { [await x]() {} } +>C : C +>[await x] : () => void +>await x : string +>x : string + export {}; diff --git a/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts b/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts index 1c2701db217..9a7f31fe53d 100644 --- a/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts +++ b/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts @@ -6,4 +6,5 @@ namespace N { class A { [await x]() {} } export class B { [await x]() {} } } +export class C { [await x]() {} } export {}; From 22be14c392099cf7eaac65fd2980e2f8493ad94f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 3 Aug 2026 19:39:28 +0000 Subject: [PATCH 3/9] Expand await-context container testcase Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- ...nNamespaceExportedClassComputedProperty.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts b/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts index 9a7f31fe53d..f8e62beb1b0 100644 --- a/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts +++ b/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts @@ -7,4 +7,25 @@ namespace N { export class B { [await x]() {} } } export class C { [await x]() {} } + +{ + export class D { [await x]() {} } +} + +function f() { + export class E { [await x]() {} } +} + +async function af() { + export class F { [await x]() {} } +} + +function* gf() { + export class G { [await x]() {} } +} + +async function* agf() { + export class H { [await x]() {} } +} + export {}; From 0d59b132332e37ef06ba9b9842b5673765b22820 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 3 Aug 2026 19:42:19 +0000 Subject: [PATCH 4/9] Accept expanded await-context baselines Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- ...ceExportedClassComputedProperty.errors.txt | 46 +++++++++++++++++- ...nNamespaceExportedClassComputedProperty.js | 46 ++++++++++++++++++ ...spaceExportedClassComputedProperty.symbols | 43 +++++++++++++++++ ...mespaceExportedClassComputedProperty.types | 48 +++++++++++++++++++ 4 files changed, 182 insertions(+), 1 deletion(-) diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt index 2aab72ccf44..3cc872908b8 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt @@ -1,8 +1,15 @@ awaitInNamespaceExportedClassComputedProperty.ts(3,16): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. awaitInNamespaceExportedClassComputedProperty.ts(4,23): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +awaitInNamespaceExportedClassComputedProperty.ts(9,5): error TS1184: Modifiers cannot appear here. +awaitInNamespaceExportedClassComputedProperty.ts(13,5): error TS1184: Modifiers cannot appear here. +awaitInNamespaceExportedClassComputedProperty.ts(13,23): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +awaitInNamespaceExportedClassComputedProperty.ts(17,5): error TS1184: Modifiers cannot appear here. +awaitInNamespaceExportedClassComputedProperty.ts(21,5): error TS1184: Modifiers cannot appear here. +awaitInNamespaceExportedClassComputedProperty.ts(21,23): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +awaitInNamespaceExportedClassComputedProperty.ts(25,5): error TS1184: Modifiers cannot appear here. -==== awaitInNamespaceExportedClassComputedProperty.ts (2 errors) ==== +==== awaitInNamespaceExportedClassComputedProperty.ts (9 errors) ==== declare const x: string; namespace N { class A { [await x]() {} } @@ -15,5 +22,42 @@ awaitInNamespaceExportedClassComputedProperty.ts(4,23): error TS1308: 'await' ex !!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:4:22: Did you mean to mark this function as 'async'? } export class C { [await x]() {} } + + { + export class D { [await x]() {} } + ~~~~~~ +!!! error TS1184: Modifiers cannot appear here. + } + + function f() { + export class E { [await x]() {} } + ~~~~~~ +!!! error TS1184: Modifiers cannot appear here. + ~~~~~ +!!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:13:22: Did you mean to mark this function as 'async'? + } + + async function af() { + export class F { [await x]() {} } + ~~~~~~ +!!! error TS1184: Modifiers cannot appear here. + } + + function* gf() { + export class G { [await x]() {} } + ~~~~~~ +!!! error TS1184: Modifiers cannot appear here. + ~~~~~ +!!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:21:22: Did you mean to mark this function as 'async'? + } + + async function* agf() { + export class H { [await x]() {} } + ~~~~~~ +!!! error TS1184: Modifiers cannot appear here. + } + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js index 0e7714f6de1..8323785aa14 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js @@ -7,6 +7,27 @@ namespace N { export class B { [await x]() {} } } export class C { [await x]() {} } + +{ + export class D { [await x]() {} } +} + +function f() { + export class E { [await x]() {} } +} + +async function af() { + export class F { [await x]() {} } +} + +function* gf() { + export class G { [await x]() {} } +} + +async function* agf() { + export class H { [await x]() {} } +} + export {}; @@ -24,3 +45,28 @@ var N; export class C { [await x]() { } } +{ + export class D { + [await x]() { } + } +} +function f() { + export class E { + [await x]() { } + } +} +async function af() { + export class F { + [await x]() { } + } +} +function* gf() { + export class G { + [await x]() { } + } +} +async function* agf() { + export class H { + [await x]() { } + } +} diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols index 1219dfd73b9..29b587b67e1 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols @@ -22,5 +22,48 @@ export class C { [await x]() {} } >[await x] : Symbol(C[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 5, 16)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) +{ + export class D { [await x]() {} } +>D : Symbol(D, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 7, 1)) +>[await x] : Symbol(D[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 8, 20)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) +} + +function f() { +>f : Symbol(f, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 9, 1)) + + export class E { [await x]() {} } +>E : Symbol(E, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 11, 14)) +>[await x] : Symbol(E[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 12, 20)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) +} + +async function af() { +>af : Symbol(af, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 13, 1)) + + export class F { [await x]() {} } +>F : Symbol(F, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 15, 21)) +>[await x] : Symbol(F[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 16, 20)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) +} + +function* gf() { +>gf : Symbol(gf, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 17, 1)) + + export class G { [await x]() {} } +>G : Symbol(G, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 19, 16)) +>[await x] : Symbol(G[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 20, 20)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) +} + +async function* agf() { +>agf : Symbol(agf, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 21, 1)) + + export class H { [await x]() {} } +>H : Symbol(H, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 23, 23)) +>[await x] : Symbol(H[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 24, 20)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) +} + export {}; diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types index 5969f54087d..39a3a3d8714 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types @@ -25,5 +25,53 @@ export class C { [await x]() {} } >await x : string >x : string +{ + export class D { [await x]() {} } +>D : D +>[await x] : () => void +>await x : string +>x : string +} + +function f() { +>f : () => void + + export class E { [await x]() {} } +>E : E +>[await x] : () => void +>await x : string +>x : string +} + +async function af() { +>af : () => Promise + + export class F { [await x]() {} } +>F : F +>[await x] : () => void +>await x : string +>x : string +} + +function* gf() { +>gf : () => Generator + + export class G { [await x]() {} } +>G : G +>[await x] : () => void +>await x : string +>x : string +} + +async function* agf() { +>agf : () => AsyncGenerator + + export class H { [await x]() {} } +>H : H +>[await x] : () => void +>await x : string +>x : string +} + export {}; From 613c992b9c217d6bc257e80b7e0fce414c94ceba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 3 Aug 2026 19:58:56 +0000 Subject: [PATCH 5/9] Cover switch await contexts Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- ...ceExportedClassComputedProperty.errors.txt | 26 +++++++++++++- ...nNamespaceExportedClassComputedProperty.js | 30 ++++++++++++++++ ...spaceExportedClassComputedProperty.symbols | 24 +++++++++++++ ...mespaceExportedClassComputedProperty.types | 34 +++++++++++++++++++ ...nNamespaceExportedClassComputedProperty.ts | 14 ++++++++ 5 files changed, 127 insertions(+), 1 deletion(-) diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt index 3cc872908b8..bc88ef26fa7 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt @@ -7,9 +7,12 @@ awaitInNamespaceExportedClassComputedProperty.ts(17,5): error TS1184: Modifiers awaitInNamespaceExportedClassComputedProperty.ts(21,5): error TS1184: Modifiers cannot appear here. awaitInNamespaceExportedClassComputedProperty.ts(21,23): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. awaitInNamespaceExportedClassComputedProperty.ts(25,5): error TS1184: Modifiers cannot appear here. +awaitInNamespaceExportedClassComputedProperty.ts(31,13): error TS1184: Modifiers cannot appear here. +awaitInNamespaceExportedClassComputedProperty.ts(31,31): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +awaitInNamespaceExportedClassComputedProperty.ts(38,13): error TS1184: Modifiers cannot appear here. -==== awaitInNamespaceExportedClassComputedProperty.ts (9 errors) ==== +==== awaitInNamespaceExportedClassComputedProperty.ts (12 errors) ==== declare const x: string; namespace N { class A { [await x]() {} } @@ -59,5 +62,26 @@ awaitInNamespaceExportedClassComputedProperty.ts(25,5): error TS1184: Modifiers !!! error TS1184: Modifiers cannot appear here. } + function switchSync() { + switch (0) { + case 0: + export class I { [await x]() {} } + ~~~~~~ +!!! error TS1184: Modifiers cannot appear here. + ~~~~~ +!!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:31:30: Did you mean to mark this function as 'async'? + } + } + + async function switchAsync() { + switch (0) { + case 0: + export class J { [await x]() {} } + ~~~~~~ +!!! error TS1184: Modifiers cannot appear here. + } + } + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js index 8323785aa14..0274247850a 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js @@ -28,6 +28,20 @@ async function* agf() { export class H { [await x]() {} } } +function switchSync() { + switch (0) { + case 0: + export class I { [await x]() {} } + } +} + +async function switchAsync() { + switch (0) { + case 0: + export class J { [await x]() {} } + } +} + export {}; @@ -70,3 +84,19 @@ async function* agf() { [await x]() { } } } +function switchSync() { + switch (0) { + case 0: + export class I { + [await x]() { } + } + } +} +async function switchAsync() { + switch (0) { + case 0: + export class J { + [await x]() { } + } + } +} diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols index 29b587b67e1..b2231a32aa1 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols @@ -65,5 +65,29 @@ async function* agf() { >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } +function switchSync() { +>switchSync : Symbol(switchSync, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 25, 1)) + + switch (0) { + case 0: + export class I { [await x]() {} } +>I : Symbol(I, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 29, 15)) +>[await x] : Symbol(I[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 30, 28)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) + } +} + +async function switchAsync() { +>switchAsync : Symbol(switchAsync, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 32, 1)) + + switch (0) { + case 0: + export class J { [await x]() {} } +>J : Symbol(J, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 36, 15)) +>[await x] : Symbol(J[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 37, 28)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) + } +} + export {}; diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types index 39a3a3d8714..523436da4b7 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types @@ -73,5 +73,39 @@ async function* agf() { >x : string } +function switchSync() { +>switchSync : () => void + + switch (0) { +>0 : 0 + + case 0: +>0 : 0 + + export class I { [await x]() {} } +>I : I +>[await x] : () => void +>await x : string +>x : string + } +} + +async function switchAsync() { +>switchAsync : () => Promise + + switch (0) { +>0 : 0 + + case 0: +>0 : 0 + + export class J { [await x]() {} } +>J : J +>[await x] : () => void +>await x : string +>x : string + } +} + export {}; diff --git a/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts b/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts index f8e62beb1b0..5fbbf9ee6fc 100644 --- a/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts +++ b/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts @@ -28,4 +28,18 @@ async function* agf() { export class H { [await x]() {} } } +function switchSync() { + switch (0) { + case 0: + export class I { [await x]() {} } + } +} + +async function switchAsync() { + switch (0) { + case 0: + export class J { [await x]() {} } + } +} + export {}; From 0a8228d11c6bfb67f362d8728584aaf8aa368ac7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 3 Aug 2026 20:22:14 +0000 Subject: [PATCH 6/9] Use valid class declarations in await test Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- ...ceExportedClassComputedProperty.errors.txt | 55 ++++++------------- ...nNamespaceExportedClassComputedProperty.js | 28 +++++----- ...spaceExportedClassComputedProperty.symbols | 28 +++++----- ...mespaceExportedClassComputedProperty.types | 14 ++--- ...nNamespaceExportedClassComputedProperty.ts | 14 ++--- 5 files changed, 59 insertions(+), 80 deletions(-) diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt index bc88ef26fa7..cbb1568bd86 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt @@ -1,18 +1,11 @@ awaitInNamespaceExportedClassComputedProperty.ts(3,16): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. awaitInNamespaceExportedClassComputedProperty.ts(4,23): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -awaitInNamespaceExportedClassComputedProperty.ts(9,5): error TS1184: Modifiers cannot appear here. -awaitInNamespaceExportedClassComputedProperty.ts(13,5): error TS1184: Modifiers cannot appear here. -awaitInNamespaceExportedClassComputedProperty.ts(13,23): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -awaitInNamespaceExportedClassComputedProperty.ts(17,5): error TS1184: Modifiers cannot appear here. -awaitInNamespaceExportedClassComputedProperty.ts(21,5): error TS1184: Modifiers cannot appear here. -awaitInNamespaceExportedClassComputedProperty.ts(21,23): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -awaitInNamespaceExportedClassComputedProperty.ts(25,5): error TS1184: Modifiers cannot appear here. -awaitInNamespaceExportedClassComputedProperty.ts(31,13): error TS1184: Modifiers cannot appear here. -awaitInNamespaceExportedClassComputedProperty.ts(31,31): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -awaitInNamespaceExportedClassComputedProperty.ts(38,13): error TS1184: Modifiers cannot appear here. +awaitInNamespaceExportedClassComputedProperty.ts(13,16): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +awaitInNamespaceExportedClassComputedProperty.ts(21,16): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +awaitInNamespaceExportedClassComputedProperty.ts(31,24): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -==== awaitInNamespaceExportedClassComputedProperty.ts (12 errors) ==== +==== awaitInNamespaceExportedClassComputedProperty.ts (5 errors) ==== declare const x: string; namespace N { class A { [await x]() {} } @@ -27,59 +20,45 @@ awaitInNamespaceExportedClassComputedProperty.ts(38,13): error TS1184: Modifiers export class C { [await x]() {} } { - export class D { [await x]() {} } - ~~~~~~ -!!! error TS1184: Modifiers cannot appear here. + class D { [await x]() {} } } function f() { - export class E { [await x]() {} } - ~~~~~~ -!!! error TS1184: Modifiers cannot appear here. - ~~~~~ + class E { [await x]() {} } + ~~~~~ !!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:13:22: Did you mean to mark this function as 'async'? +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:13:15: Did you mean to mark this function as 'async'? } async function af() { - export class F { [await x]() {} } - ~~~~~~ -!!! error TS1184: Modifiers cannot appear here. + class F { [await x]() {} } } function* gf() { - export class G { [await x]() {} } - ~~~~~~ -!!! error TS1184: Modifiers cannot appear here. - ~~~~~ + class G { [await x]() {} } + ~~~~~ !!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:21:22: Did you mean to mark this function as 'async'? +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:21:15: Did you mean to mark this function as 'async'? } async function* agf() { - export class H { [await x]() {} } - ~~~~~~ -!!! error TS1184: Modifiers cannot appear here. + class H { [await x]() {} } } function switchSync() { switch (0) { case 0: - export class I { [await x]() {} } - ~~~~~~ -!!! error TS1184: Modifiers cannot appear here. - ~~~~~ + class I { [await x]() {} } + ~~~~~ !!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:31:30: Did you mean to mark this function as 'async'? +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:31:23: Did you mean to mark this function as 'async'? } } async function switchAsync() { switch (0) { case 0: - export class J { [await x]() {} } - ~~~~~~ -!!! error TS1184: Modifiers cannot appear here. + class J { [await x]() {} } } } diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js index 0274247850a..3681cd4e90d 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js @@ -9,36 +9,36 @@ namespace N { export class C { [await x]() {} } { - export class D { [await x]() {} } + class D { [await x]() {} } } function f() { - export class E { [await x]() {} } + class E { [await x]() {} } } async function af() { - export class F { [await x]() {} } + class F { [await x]() {} } } function* gf() { - export class G { [await x]() {} } + class G { [await x]() {} } } async function* agf() { - export class H { [await x]() {} } + class H { [await x]() {} } } function switchSync() { switch (0) { case 0: - export class I { [await x]() {} } + class I { [await x]() {} } } } async function switchAsync() { switch (0) { case 0: - export class J { [await x]() {} } + class J { [await x]() {} } } } @@ -60,34 +60,34 @@ export class C { [await x]() { } } { - export class D { + class D { [await x]() { } } } function f() { - export class E { + class E { [await x]() { } } } async function af() { - export class F { + class F { [await x]() { } } } function* gf() { - export class G { + class G { [await x]() { } } } async function* agf() { - export class H { + class H { [await x]() { } } } function switchSync() { switch (0) { case 0: - export class I { + class I { [await x]() { } } } @@ -95,7 +95,7 @@ function switchSync() { async function switchAsync() { switch (0) { case 0: - export class J { + class J { [await x]() { } } } diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols index b2231a32aa1..05486ed7c82 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols @@ -23,45 +23,45 @@ export class C { [await x]() {} } >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) { - export class D { [await x]() {} } + class D { [await x]() {} } >D : Symbol(D, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 7, 1)) ->[await x] : Symbol(D[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 8, 20)) +>[await x] : Symbol(D[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 8, 13)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } function f() { >f : Symbol(f, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 9, 1)) - export class E { [await x]() {} } + class E { [await x]() {} } >E : Symbol(E, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 11, 14)) ->[await x] : Symbol(E[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 12, 20)) +>[await x] : Symbol(E[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 12, 13)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } async function af() { >af : Symbol(af, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 13, 1)) - export class F { [await x]() {} } + class F { [await x]() {} } >F : Symbol(F, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 15, 21)) ->[await x] : Symbol(F[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 16, 20)) +>[await x] : Symbol(F[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 16, 13)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } function* gf() { >gf : Symbol(gf, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 17, 1)) - export class G { [await x]() {} } + class G { [await x]() {} } >G : Symbol(G, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 19, 16)) ->[await x] : Symbol(G[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 20, 20)) +>[await x] : Symbol(G[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 20, 13)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } async function* agf() { >agf : Symbol(agf, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 21, 1)) - export class H { [await x]() {} } + class H { [await x]() {} } >H : Symbol(H, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 23, 23)) ->[await x] : Symbol(H[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 24, 20)) +>[await x] : Symbol(H[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 24, 13)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } @@ -70,9 +70,9 @@ function switchSync() { switch (0) { case 0: - export class I { [await x]() {} } + class I { [await x]() {} } >I : Symbol(I, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 29, 15)) ->[await x] : Symbol(I[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 30, 28)) +>[await x] : Symbol(I[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 30, 21)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } } @@ -82,9 +82,9 @@ async function switchAsync() { switch (0) { case 0: - export class J { [await x]() {} } + class J { [await x]() {} } >J : Symbol(J, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 36, 15)) ->[await x] : Symbol(J[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 37, 28)) +>[await x] : Symbol(J[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 37, 21)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } } diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types index 523436da4b7..693db18fda4 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types @@ -26,7 +26,7 @@ export class C { [await x]() {} } >x : string { - export class D { [await x]() {} } + class D { [await x]() {} } >D : D >[await x] : () => void >await x : string @@ -36,7 +36,7 @@ export class C { [await x]() {} } function f() { >f : () => void - export class E { [await x]() {} } + class E { [await x]() {} } >E : E >[await x] : () => void >await x : string @@ -46,7 +46,7 @@ function f() { async function af() { >af : () => Promise - export class F { [await x]() {} } + class F { [await x]() {} } >F : F >[await x] : () => void >await x : string @@ -56,7 +56,7 @@ async function af() { function* gf() { >gf : () => Generator - export class G { [await x]() {} } + class G { [await x]() {} } >G : G >[await x] : () => void >await x : string @@ -66,7 +66,7 @@ function* gf() { async function* agf() { >agf : () => AsyncGenerator - export class H { [await x]() {} } + class H { [await x]() {} } >H : H >[await x] : () => void >await x : string @@ -82,7 +82,7 @@ function switchSync() { case 0: >0 : 0 - export class I { [await x]() {} } + class I { [await x]() {} } >I : I >[await x] : () => void >await x : string @@ -99,7 +99,7 @@ async function switchAsync() { case 0: >0 : 0 - export class J { [await x]() {} } + class J { [await x]() {} } >J : J >[await x] : () => void >await x : string diff --git a/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts b/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts index 5fbbf9ee6fc..4c4b9613583 100644 --- a/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts +++ b/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts @@ -9,36 +9,36 @@ namespace N { export class C { [await x]() {} } { - export class D { [await x]() {} } + class D { [await x]() {} } } function f() { - export class E { [await x]() {} } + class E { [await x]() {} } } async function af() { - export class F { [await x]() {} } + class F { [await x]() {} } } function* gf() { - export class G { [await x]() {} } + class G { [await x]() {} } } async function* agf() { - export class H { [await x]() {} } + class H { [await x]() {} } } function switchSync() { switch (0) { case 0: - export class I { [await x]() {} } + class I { [await x]() {} } } } async function switchAsync() { switch (0) { case 0: - export class J { [await x]() {} } + class J { [await x]() {} } } } From 97b188bc6d9632d9e16c4fa78b6d3f33224ec811 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 3 Aug 2026 13:45:45 -0700 Subject: [PATCH 7/9] Apply suggestion from @RyanCavanaugh Move cheaper check prior in short-circuit --- internal/parser/parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/parser/parser.go b/internal/parser/parser.go index fcb177c6bd5..dbc7ed515c8 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -1748,7 +1748,7 @@ func (p *Parser) parseClassDeclarationOrExpression(pos int, jsdoc jsdocScannerIn // We don't parse the name here in await context, instead we will report a grammar error in the checker. name := p.parseNameOfClassDeclarationOrExpression() typeParameters := p.parseTypeParameters() - if modifiers != nil && core.Some(modifiers.Nodes, isExportModifier) && p.parsingContexts == 1< Date: Fri, 7 Aug 2026 22:10:59 +0000 Subject: [PATCH 8/9] Add static await-context regression coverage Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- ...ceExportedClassComputedProperty.errors.txt | 50 ++++++++---- ...nNamespaceExportedClassComputedProperty.js | 24 +++++- ...spaceExportedClassComputedProperty.symbols | 80 +++++++++++++------ ...mespaceExportedClassComputedProperty.types | 40 +++++++++- ...nNamespaceExportedClassComputedProperty.ts | 20 ++++- 5 files changed, 161 insertions(+), 53 deletions(-) diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt index cbb1568bd86..e8f59d34eb9 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.errors.txt @@ -1,44 +1,64 @@ awaitInNamespaceExportedClassComputedProperty.ts(3,16): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -awaitInNamespaceExportedClassComputedProperty.ts(4,23): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -awaitInNamespaceExportedClassComputedProperty.ts(13,16): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -awaitInNamespaceExportedClassComputedProperty.ts(21,16): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -awaitInNamespaceExportedClassComputedProperty.ts(31,24): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +awaitInNamespaceExportedClassComputedProperty.ts(5,10): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +awaitInNamespaceExportedClassComputedProperty.ts(6,17): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +awaitInNamespaceExportedClassComputedProperty.ts(20,10): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +awaitInNamespaceExportedClassComputedProperty.ts(21,17): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +awaitInNamespaceExportedClassComputedProperty.ts(33,16): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +awaitInNamespaceExportedClassComputedProperty.ts(43,24): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -==== awaitInNamespaceExportedClassComputedProperty.ts (5 errors) ==== +==== awaitInNamespaceExportedClassComputedProperty.ts (7 errors) ==== declare const x: string; namespace N { class A { [await x]() {} } ~~~~~ !!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. !!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:3:15: Did you mean to mark this function as 'async'? - export class B { [await x]() {} } - ~~~~~ + export class B { + [await x]() {} + ~~~~~ !!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:4:22: Did you mean to mark this function as 'async'? +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:5:9: Did you mean to mark this function as 'async'? + static [await x]() {} + ~~~~~ +!!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:6:16: Did you mean to mark this function as 'async'? + } + } + export class C { + [await x]() {} + static [await x]() {} } - export class C { [await x]() {} } { class D { [await x]() {} } } function f() { - class E { [await x]() {} } - ~~~~~ + class E { + [await x]() {} + ~~~~~ !!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:13:15: Did you mean to mark this function as 'async'? +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:20:9: Did you mean to mark this function as 'async'? + static [await x]() {} + ~~~~~ +!!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:21:16: Did you mean to mark this function as 'async'? + } } async function af() { - class F { [await x]() {} } + class F { + [await x]() {} + static [await x]() {} + } } function* gf() { class G { [await x]() {} } ~~~~~ !!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:21:15: Did you mean to mark this function as 'async'? +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:33:15: Did you mean to mark this function as 'async'? } async function* agf() { @@ -51,7 +71,7 @@ awaitInNamespaceExportedClassComputedProperty.ts(31,24): error TS1308: 'await' e class I { [await x]() {} } ~~~~~ !!! error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:31:23: Did you mean to mark this function as 'async'? +!!! related TS1356 awaitInNamespaceExportedClassComputedProperty.ts:43:23: Did you mean to mark this function as 'async'? } } diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js index 3681cd4e90d..17731877baf 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.js @@ -4,20 +4,32 @@ declare const x: string; namespace N { class A { [await x]() {} } - export class B { [await x]() {} } + export class B { + [await x]() {} + static [await x]() {} + } +} +export class C { + [await x]() {} + static [await x]() {} } -export class C { [await x]() {} } { class D { [await x]() {} } } function f() { - class E { [await x]() {} } + class E { + [await x]() {} + static [await x]() {} + } } async function af() { - class F { [await x]() {} } + class F { + [await x]() {} + static [await x]() {} + } } function* gf() { @@ -53,11 +65,13 @@ var N; } class B { [await x]() { } + static [await x]() { } } N.B = B; })(N || (N = {})); export class C { [await x]() { } + static [await x]() { } } { class D { @@ -67,11 +81,13 @@ export class C { function f() { class E { [await x]() { } + static [await x]() { } } } async function af() { class F { [await x]() { } + static [await x]() { } } } function* gf() { diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols index 05486ed7c82..06cce75f614 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.symbols @@ -12,79 +12,107 @@ namespace N { >[await x] : Symbol(A[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 2, 13)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) - export class B { [await x]() {} } + export class B { >B : Symbol(B, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 2, 30)) + + [await x]() {} >[await x] : Symbol(B[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 3, 20)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) + + static [await x]() {} +>[await x] : Symbol(B[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 4, 22)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) + } } -export class C { [await x]() {} } ->C : Symbol(C, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 4, 1)) ->[await x] : Symbol(C[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 5, 16)) +export class C { +>C : Symbol(C, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 7, 1)) + + [await x]() {} +>[await x] : Symbol(C[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 8, 16)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) + + static [await x]() {} +>[await x] : Symbol(C[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 9, 18)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) +} { class D { [await x]() {} } ->D : Symbol(D, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 7, 1)) ->[await x] : Symbol(D[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 8, 13)) +>D : Symbol(D, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 13, 1)) +>[await x] : Symbol(D[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 14, 13)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } function f() { ->f : Symbol(f, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 9, 1)) +>f : Symbol(f, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 15, 1)) - class E { [await x]() {} } ->E : Symbol(E, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 11, 14)) ->[await x] : Symbol(E[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 12, 13)) + class E { +>E : Symbol(E, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 17, 14)) + + [await x]() {} +>[await x] : Symbol(E[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 18, 13)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) + + static [await x]() {} +>[await x] : Symbol(E[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 19, 22)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) + } } async function af() { ->af : Symbol(af, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 13, 1)) +>af : Symbol(af, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 22, 1)) - class F { [await x]() {} } ->F : Symbol(F, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 15, 21)) ->[await x] : Symbol(F[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 16, 13)) + class F { +>F : Symbol(F, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 24, 21)) + + [await x]() {} +>[await x] : Symbol(F[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 25, 13)) +>x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) + + static [await x]() {} +>[await x] : Symbol(F[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 26, 22)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) + } } function* gf() { ->gf : Symbol(gf, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 17, 1)) +>gf : Symbol(gf, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 29, 1)) class G { [await x]() {} } ->G : Symbol(G, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 19, 16)) ->[await x] : Symbol(G[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 20, 13)) +>G : Symbol(G, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 31, 16)) +>[await x] : Symbol(G[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 32, 13)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } async function* agf() { ->agf : Symbol(agf, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 21, 1)) +>agf : Symbol(agf, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 33, 1)) class H { [await x]() {} } ->H : Symbol(H, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 23, 23)) ->[await x] : Symbol(H[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 24, 13)) +>H : Symbol(H, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 35, 23)) +>[await x] : Symbol(H[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 36, 13)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } function switchSync() { ->switchSync : Symbol(switchSync, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 25, 1)) +>switchSync : Symbol(switchSync, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 37, 1)) switch (0) { case 0: class I { [await x]() {} } ->I : Symbol(I, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 29, 15)) ->[await x] : Symbol(I[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 30, 21)) +>I : Symbol(I, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 41, 15)) +>[await x] : Symbol(I[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 42, 21)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } } async function switchAsync() { ->switchAsync : Symbol(switchAsync, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 32, 1)) +>switchAsync : Symbol(switchAsync, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 44, 1)) switch (0) { case 0: class J { [await x]() {} } ->J : Symbol(J, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 36, 15)) ->[await x] : Symbol(J[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 37, 21)) +>J : Symbol(J, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 48, 15)) +>[await x] : Symbol(J[await x], Decl(awaitInNamespaceExportedClassComputedProperty.ts, 49, 21)) >x : Symbol(x, Decl(awaitInNamespaceExportedClassComputedProperty.ts, 0, 13)) } } diff --git a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types index 693db18fda4..b9ff07222f6 100644 --- a/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types +++ b/testdata/baselines/reference/compiler/awaitInNamespaceExportedClassComputedProperty.types @@ -13,17 +13,33 @@ namespace N { >await x : string >x : string - export class B { [await x]() {} } + export class B { >B : B + + [await x]() {} +>[await x] : () => void +>await x : string +>x : string + + static [await x]() {} >[await x] : () => void >await x : string >x : string + } } -export class C { [await x]() {} } +export class C { >C : C + + [await x]() {} +>[await x] : () => void +>await x : string +>x : string + + static [await x]() {} >[await x] : () => void >await x : string >x : string +} { class D { [await x]() {} } @@ -36,21 +52,37 @@ export class C { [await x]() {} } function f() { >f : () => void - class E { [await x]() {} } + class E { >E : E + + [await x]() {} +>[await x] : () => void +>await x : string +>x : string + + static [await x]() {} >[await x] : () => void >await x : string >x : string + } } async function af() { >af : () => Promise - class F { [await x]() {} } + class F { >F : F + + [await x]() {} +>[await x] : () => void +>await x : string +>x : string + + static [await x]() {} >[await x] : () => void >await x : string >x : string + } } function* gf() { diff --git a/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts b/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts index 4c4b9613583..7dae8cf3838 100644 --- a/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts +++ b/testdata/tests/cases/compiler/awaitInNamespaceExportedClassComputedProperty.ts @@ -4,20 +4,32 @@ declare const x: string; namespace N { class A { [await x]() {} } - export class B { [await x]() {} } + export class B { + [await x]() {} + static [await x]() {} + } +} +export class C { + [await x]() {} + static [await x]() {} } -export class C { [await x]() {} } { class D { [await x]() {} } } function f() { - class E { [await x]() {} } + class E { + [await x]() {} + static [await x]() {} + } } async function af() { - class F { [await x]() {} } + class F { + [await x]() {} + static [await x]() {} + } } function* gf() { From e7130af9c5da78acf6fb5fa342380fafec33188f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Aug 2026 00:26:22 +0000 Subject: [PATCH 9/9] Use bitwise context checks for exported class await context Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- internal/parser/parser.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/parser/parser.go b/internal/parser/parser.go index dbc7ed515c8..963df72e01f 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -1748,7 +1748,10 @@ func (p *Parser) parseClassDeclarationOrExpression(pos int, jsdoc jsdocScannerIn // We don't parse the name here in await context, instead we will report a grammar error in the checker. name := p.parseNameOfClassDeclarationOrExpression() typeParameters := p.parseTypeParameters() - if modifiers != nil && p.parsingContexts == 1<