diff --git a/crates/oxc_linter/src/snapshots/unicorn_prefer_logical_operator_over_ternary.snap b/crates/oxc_linter/src/snapshots/unicorn_prefer_logical_operator_over_ternary.snap index b13daeaf1659a..f58c0e5b49340 100644 --- a/crates/oxc_linter/src/snapshots/unicorn_prefer_logical_operator_over_ternary.snap +++ b/crates/oxc_linter/src/snapshots/unicorn_prefer_logical_operator_over_ternary.snap @@ -92,47 +92,40 @@ source: crates/oxc_linter/src/tester.rs ╰──── help: Switch to "||" or "??" operator - × `await` is only allowed within async functions and at the top levels of modules - ╭─[prefer_logical_operator_over_ternary.tsx:1:13] + ⚠ eslint-plugin-unicorn(prefer-logical-operator-over-ternary): Prefer using a logical operator over a ternary. + ╭─[prefer_logical_operator_over_ternary.tsx:1:1] 1 │ foo ? foo : await a - · ───── + · ─────────────────── ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function + help: Switch to "||" or "??" operator - × `await` is only allowed within async functions and at the top levels of modules + ⚠ eslint-plugin-unicorn(prefer-logical-operator-over-ternary): Prefer using a logical operator over a ternary. ╭─[prefer_logical_operator_over_ternary.tsx:1:1] 1 │ await a ? await a : foo - · ───── + · ─────────────────────── ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function - - × `await` is only allowed within async functions and at the top levels of modules - ╭─[prefer_logical_operator_over_ternary.tsx:1:11] - 1 │ await a ? await a : foo - · ───── - ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function + help: Switch to "||" or "??" operator - × `await` is only allowed within async functions and at the top levels of modules + ⚠ eslint-plugin-unicorn(prefer-logical-operator-over-ternary): Prefer using a logical operator over a ternary. ╭─[prefer_logical_operator_over_ternary.tsx:1:1] 1 │ await a ? (await (a)) : (foo) - · ───── + · ───────────────────────────── ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function + help: Switch to "||" or "??" operator - × `await` is only allowed within async functions and at the top levels of modules - ╭─[prefer_logical_operator_over_ternary.tsx:1:2] + ⚠ eslint-plugin-unicorn(prefer-logical-operator-over-ternary): Prefer using a logical operator over a ternary. + ╭─[prefer_logical_operator_over_ternary.tsx:1:1] 1 │ (await a) ? await (a) : (foo) - · ───── + · ───────────────────────────── ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function + help: Switch to "||" or "??" operator - × `await` is only allowed within async functions and at the top levels of modules - ╭─[prefer_logical_operator_over_ternary.tsx:1:2] + ⚠ eslint-plugin-unicorn(prefer-logical-operator-over-ternary): Prefer using a logical operator over a ternary. + ╭─[prefer_logical_operator_over_ternary.tsx:1:1] 1 │ (await a) ? (await (a)) : (foo) - · ───── + · ─────────────────────────────── ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function + help: Switch to "||" or "??" operator ⚠ eslint-plugin-unicorn(prefer-logical-operator-over-ternary): Prefer using a logical operator over a ternary. ╭─[prefer_logical_operator_over_ternary.tsx:2:10] diff --git a/crates/oxc_linter/src/snapshots/unicorn_prefer_node_protocol.snap b/crates/oxc_linter/src/snapshots/unicorn_prefer_node_protocol.snap index 3fba1c243fe13..bb946d03f5eac 100644 --- a/crates/oxc_linter/src/snapshots/unicorn_prefer_node_protocol.snap +++ b/crates/oxc_linter/src/snapshots/unicorn_prefer_node_protocol.snap @@ -105,9 +105,9 @@ source: crates/oxc_linter/src/tester.rs · ── ╰──── - × `await` is only allowed within async functions and at the top levels of modules - ╭─[prefer_node_protocol.tsx:1:1] + ⚠ eslint-plugin-unicorn(prefer-node-protocol): Prefer using the `node:` protocol when importing Node.js builtin modules. + ╭─[prefer_node_protocol.tsx:1:14] 1 │ await import('assert/strict') - · ───── + · ─────────────── ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function + help: Prefer `node:assert/strict` over `assert/strict`. diff --git a/crates/oxc_linter/src/snapshots/unicorn_prefer_string_slice.snap b/crates/oxc_linter/src/snapshots/unicorn_prefer_string_slice.snap index e588771db6642..0c020d21ac1da 100644 --- a/crates/oxc_linter/src/snapshots/unicorn_prefer_string_slice.snap +++ b/crates/oxc_linter/src/snapshots/unicorn_prefer_string_slice.snap @@ -337,12 +337,12 @@ source: crates/oxc_linter/src/tester.rs ╰──── help: Replace `substring` with `slice`. - × `await` is only allowed within async functions and at the top levels of modules - ╭─[prefer_string_slice.tsx:1:18] + ⚠ eslint-plugin-unicorn(prefer-string-slice): Prefer String#slice() over String#substring() + ╭─[prefer_string_slice.tsx:1:5] 1 │ foo.substring(0, await 1) - · ───── + · ───────── ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function + help: Replace `substring` with `slice`. ⚠ eslint-plugin-unicorn(prefer-string-slice): Prefer String#slice() over String#substring() ╭─[prefer_string_slice.tsx:1:5] diff --git a/crates/oxc_parser/src/js/arrow.rs b/crates/oxc_parser/src/js/arrow.rs index bdcb1611b3485..7a07e04714462 100644 --- a/crates/oxc_parser/src/js/arrow.rs +++ b/crates/oxc_parser/src/js/arrow.rs @@ -295,8 +295,11 @@ impl<'a> ParserImpl<'a> { let expression = !self.at(Kind::LCurly); let body = if expression { + // Track function depth for expression bodies too + self.state.function_depth += 1; let expr = self .parse_assignment_expression_or_higher_impl(allow_return_type_in_arrow_function); + self.state.function_depth -= 1; let span = expr.span(); let expr_stmt = self.ast.statement_expression(span, expr); self.ast.alloc_function_body(span, self.ast.vec(), self.ast.vec1(expr_stmt)) diff --git a/crates/oxc_parser/src/js/expression.rs b/crates/oxc_parser/src/js/expression.rs index 143e14dd10d48..24f14cd3de94c 100644 --- a/crates/oxc_parser/src/js/expression.rs +++ b/crates/oxc_parser/src/js/expression.rs @@ -1139,7 +1139,7 @@ impl<'a> ParserImpl<'a> { self.unexpected() } } - Kind::Await if self.is_await_expression() => self.parse_await_expression(lhs_span), + Kind::Await => self.parse_await_expression(lhs_span), _ => self.parse_update_expression(lhs_span), } } @@ -1474,19 +1474,91 @@ impl<'a> ParserImpl<'a> { self.ast.expression_sequence(self.end_span(span), expressions) } + /// Check if the current `await` token is unambiguously an await expression. + /// + /// Based on Babel's `isAmbiguousPrefixOrIdentifier` (inverted) and + /// TypeScript's `nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine`. + /// + /// Returns `true` when await is definitely an await expression (not ambiguous). + /// + /// Unambiguous cases (returns `true`): + /// - Next token is identifier, keyword (except `of`), or literal on same line + /// + /// Ambiguous cases (returns `false`): + /// - Line break after `await` (could be ASI) + /// - Next token is `+` `-` (could be binary operator or unary prefix) + /// - Next token is `(` `[` (could be call/member or grouping/array) + /// - Next token is template literal + /// - Next token is `of` (for-await-of ambiguity: `for (await of [])`) + /// - Next token is `/` (division or regex literal) + /// - Next token cannot start an expression (`)`, `}`, `;`, etc.) + fn is_unambiguous_await(&mut self) -> bool { + let token = self.lexer.peek_token(); + + // Line break after await makes it ambiguous (could be ASI) + if token.is_on_new_line() { + return false; + } + + let kind = token.kind(); + + // Special case: `await of` is ambiguous (for-await-of loop) + // Special case: `await using` should be handled as a declaration, not `await (using)` + if matches!(kind, Kind::Of | Kind::Using) { + return false; + } + + // Returns true for identifiers, keywords, and literals (not binary operators) + kind.is_after_await_or_yield() + } + /// ``AwaitExpression`[Yield]` : /// await `UnaryExpression`[?Yield, +Await] fn parse_await_expression(&mut self, lhs_span: u32) -> Expression<'a> { - let span = self.start_span(); - if !self.ctx.has_await() { - // For `ModuleKind::Unambiguous`, defer the error until we know whether - // this is a Module (where top-level await is valid) or Script. - self.error_on_script(diagnostics::await_expression(self.cur_token().span())); + // Case 1: In await context (async function, module top-level, unambiguous mode top-level) + // Always parse as await expression + if self.ctx.has_await() { + let span = self.start_span(); + self.bump_any(); // consume `await` + let argument = self.parse_unary_expression_or_higher(self.start_span()); + return self.ast.expression_await(self.end_span(span), argument); + } + + // Case 2: Not in await context, but unambiguously an await expression + // Parse as await expression and report error for better diagnostics + // This matches Babel's behavior: report "await only allowed in async" error + // + // At top level (function_depth == 0) in unambiguous mode: unambiguous await + // upgrades the file to ESM (like Babel's `sawUnambiguousESM`). We defer the + // error with `error_on_script` - it will be discarded when we upgrade to ESM. + // + // Inside a function (function_depth > 0): await is always invalid in non-async + // functions, even in ESM. Report error immediately. + if self.is_unambiguous_await() { + let span = self.start_span(); + + if self.state.function_depth == 0 { + // At top level - set flag for statement-level ESM upgrade check + self.state.encountered_unambiguous_await = true; + // Defer error - will be discarded when we upgrade to ESM + self.error_on_script(diagnostics::await_expression(self.cur_token().span())); + } else { + // Inside a function - await is always invalid in non-async function + self.error(diagnostics::await_expression(self.cur_token().span())); + } + + self.bump_any(); // consume `await` + // Parse argument with await context enabled for this expression + self.ctx = self.ctx.and_await(true); + let argument = self.parse_unary_expression_or_higher(self.start_span()); + self.ctx = self.ctx.and_await(false); + return self.ast.expression_await(self.end_span(span), argument); } - self.bump_any(); - let argument = - self.context_add(Context::Await, |p| p.parse_simple_unary_expression(lhs_span)); - self.ast.expression_await(self.end_span(span), argument) + + // Case 3: Ambiguous - parse `await` as identifier + // This applies to scripts where `await` might be identifier or keyword + // The statement-level checkpoint system handles reparsing if ESM detected + self.parse_update_expression(lhs_span) } fn parse_decorated_expression(&mut self) -> Expression<'a> { @@ -1537,18 +1609,6 @@ impl<'a> ParserImpl<'a> { } } - fn is_await_expression(&mut self) -> bool { - if self.at(Kind::Await) { - if self.ctx.has_await() { - return true; - } - return self.lookahead(|p| { - Self::next_token_is_identifier_or_keyword_or_literal_on_same_line(p, true) - }); - } - false - } - fn is_yield_expression(&mut self) -> bool { if self.at(Kind::Yield) { if self.ctx.has_yield() { diff --git a/crates/oxc_parser/src/js/function.rs b/crates/oxc_parser/src/js/function.rs index 5402dddf255dd..662cd1e69731c 100644 --- a/crates/oxc_parser/src/js/function.rs +++ b/crates/oxc_parser/src/js/function.rs @@ -33,9 +33,11 @@ impl<'a> ParserImpl<'a> { let opening_span = self.cur_token().span(); self.expect(Kind::LCurly); + self.state.function_depth += 1; let (directives, statements) = self.context_add(Context::Return, |p| { p.parse_directives_and_statements(/* is_top_level */ false) }); + self.state.function_depth -= 1; self.expect_closing(Kind::RCurly, opening_span); self.ast.alloc_function_body(self.end_span(span), directives, statements) diff --git a/crates/oxc_parser/src/js/statement.rs b/crates/oxc_parser/src/js/statement.rs index e84e34d75a252..9ff684fec2270 100644 --- a/crates/oxc_parser/src/js/statement.rs +++ b/crates/oxc_parser/src/js/statement.rs @@ -61,10 +61,11 @@ impl<'a> ParserImpl<'a> { } // Take checkpoint for every statement when tracking await reparse. - // We reset the flag and only store the checkpoint if an await identifier + // We reset the flags and only store the checkpoint if an await identifier // was actually encountered during parsing. let checkpoint = if track_await_reparse { self.state.encountered_await_identifier = false; + self.state.encountered_unambiguous_await = false; Some((statements.len(), self.checkpoint())) } else { None @@ -72,6 +73,14 @@ impl<'a> ParserImpl<'a> { let stmt = self.parse_statement_list_item(stmt_ctx); + // If unambiguous await was encountered at top level, upgrade to ESM + // This is like Babel's `sawUnambiguousESM` flag + if track_await_reparse && self.state.encountered_unambiguous_await { + self.module_record_builder.found_unambiguous_await(); + track_await_reparse = false; + self.ctx = self.ctx.and_await(true); + } + // Store checkpoint only if await identifier was encountered if let Some((stmt_index, checkpoint)) = checkpoint && self.state.encountered_await_identifier diff --git a/crates/oxc_parser/src/module_record.rs b/crates/oxc_parser/src/module_record.rs index 190efdb4f217c..eb44925243c40 100644 --- a/crates/oxc_parser/src/module_record.rs +++ b/crates/oxc_parser/src/module_record.rs @@ -387,6 +387,12 @@ impl<'a> ModuleRecordBuilder<'a> { pub fn found_ts_export(&mut self) { self.module_record.has_module_syntax = true; } + + /// Mark the file as ESM when unambiguous top-level await is detected. + /// This is similar to Babel's `sawUnambiguousESM` flag. + pub fn found_unambiguous_await(&mut self) { + self.module_record.has_module_syntax = true; + } } fn iter_binding_identifiers_of_declaration<'a, F>(decl: &Declaration<'a>, f: &mut F) diff --git a/crates/oxc_parser/src/state.rs b/crates/oxc_parser/src/state.rs index 3d5cade581102..9ccedf0dc694b 100644 --- a/crates/oxc_parser/src/state.rs +++ b/crates/oxc_parser/src/state.rs @@ -31,6 +31,14 @@ pub struct ParserState<'a> { /// Used to determine if a statement needs to be stored for potential reparsing /// in unambiguous mode. pub encountered_await_identifier: bool, + + /// Flag to track if an unambiguous await expression was encountered during statement parsing. + /// Used to upgrade to ESM when top-level unambiguous await is detected. + pub encountered_unambiguous_await: bool, + + /// Depth counter for function body parsing. + /// Used to detect if we're inside a function body (depth > 0) vs at top level (depth == 0). + pub function_depth: u32, } impl ParserState<'_> { @@ -41,6 +49,8 @@ impl ParserState<'_> { trailing_commas: FxHashMap::default(), potential_await_reparse: Vec::new(), encountered_await_identifier: false, + encountered_unambiguous_await: false, + function_depth: 0, } } } diff --git a/tasks/coverage/snapshots/codegen_misc.snap b/tasks/coverage/snapshots/codegen_misc.snap index 61470560f890a..e8cc6977d765c 100644 --- a/tasks/coverage/snapshots/codegen_misc.snap +++ b/tasks/coverage/snapshots/codegen_misc.snap @@ -1,5 +1,3 @@ codegen_misc Summary: AST Parsed : 64/64 (100.00%) -Positive Passed: 63/64 (98.44%) -Normal: tasks/coverage/misc/pass/babel-16776-s.js - +Positive Passed: 64/64 (100.00%) diff --git a/tasks/coverage/snapshots/parser_misc.snap b/tasks/coverage/snapshots/parser_misc.snap index 74d6d2ef6dc8e..8bc04a79738f2 100644 --- a/tasks/coverage/snapshots/parser_misc.snap +++ b/tasks/coverage/snapshots/parser_misc.snap @@ -438,14 +438,14 @@ Negative Passed: 133/133 (100.00%) · ╰── `b` has already been declared here ╰──── - × `await` is only allowed within async functions and at the top levels of modules - ╭─[misc/fail/oxc-10503.ts:4:1] + × Expected a semicolon or an implicit semicolon after a statement, but found none + ╭─[misc/fail/oxc-10503.ts:4:6] 3 │ 4 │ await using - · ───── + · ▲ 5 │ foo = bar(); ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function + help: Try inserting a semicolon here × Unexpected token ╭─[misc/fail/oxc-10638.js:2:1] diff --git a/tasks/coverage/snapshots/parser_typescript.snap b/tasks/coverage/snapshots/parser_typescript.snap index 2c4bd01801704..48b97d58b5c50 100644 --- a/tasks/coverage/snapshots/parser_typescript.snap +++ b/tasks/coverage/snapshots/parser_typescript.snap @@ -56,8 +56,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/autolift4.ts Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/awaitCallExpressionInSyncFunction.ts -Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/awaitInNonAsyncFunction.ts - Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/baseCheck.ts Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/baseExpressionTypeParameters.ts @@ -1484,6 +1482,8 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/externalM Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/externalModules/rewriteRelativeImportExtensions/emit.ts +Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/externalModules/topLevelAwaitNonModule.ts + Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/externalModules/topLevelModuleDeclarationAndFile.ts Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/externalModules/typeOnly/chained2.ts @@ -3127,6 +3127,69 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Either remove this `await` or add the `async` keyword to the enclosing function + × `await` is only allowed within async functions and at the top levels of modules + ╭─[typescript/tests/cases/compiler/awaitInNonAsyncFunction.ts:5:10] + 4 │ for await (const _ of []); + 5 │ return await p; + · ───── + 6 │ } + ╰──── + help: Either remove this `await` or add the `async` keyword to the enclosing function + + × `await` is only allowed within async functions and at the top levels of modules + ╭─[typescript/tests/cases/compiler/awaitInNonAsyncFunction.ts:10:10] + 9 │ for await (const _ of []); + 10 │ return await p; + · ───── + 11 │ } + ╰──── + help: Either remove this `await` or add the `async` keyword to the enclosing function + + × `await` is only allowed within async functions and at the top levels of modules + ╭─[typescript/tests/cases/compiler/awaitInNonAsyncFunction.ts:15:3] + 14 │ for await (const _ of []); + 15 │ await p; + · ───── + 16 │ } + ╰──── + help: Either remove this `await` or add the `async` keyword to the enclosing function + + × `await` is only allowed within async functions and at the top levels of modules + ╭─[typescript/tests/cases/compiler/awaitInNonAsyncFunction.ts:20:10] + 19 │ for await (const _ of []); + 20 │ return await p; + · ───── + 21 │ }; + ╰──── + help: Either remove this `await` or add the `async` keyword to the enclosing function + + × `await` is only allowed within async functions and at the top levels of modules + ╭─[typescript/tests/cases/compiler/awaitInNonAsyncFunction.ts:25:9] + 24 │ for await (const _ of []); + 25 │ yield await p; + · ───── + 26 │ } + ╰──── + help: Either remove this `await` or add the `async` keyword to the enclosing function + + × `await` is only allowed within async functions and at the top levels of modules + ╭─[typescript/tests/cases/compiler/awaitInNonAsyncFunction.ts:31:5] + 30 │ for await (const _ of []); + 31 │ await p; + · ───── + 32 │ } + ╰──── + help: Either remove this `await` or add the `async` keyword to the enclosing function + + × `await` is only allowed within async functions and at the top levels of modules + ╭─[typescript/tests/cases/compiler/awaitInNonAsyncFunction.ts:35:5] + 34 │ for await (const _ of []); + 35 │ await p; + · ───── + 36 │ } + ╰──── + help: Either remove this `await` or add the `async` keyword to the enclosing function + × `await` is only allowed within async functions and at the top levels of modules ╭─[typescript/tests/cases/compiler/awaitLiteralValues.ts:2:5] 1 │ function awaitString() { @@ -12621,42 +12684,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va 47 │ } ╰──── - × A 'yield' expression is only allowed in a generator body. - ╭─[typescript/tests/cases/conformance/classes/awaitAndYieldInProperty.ts:6:21] - 5 │ - 6 │ [yield 1] = yield 2; - · ───── - 7 │ static [yield 3] = yield 4; - ╰──── - help: Either remove this `yield` or change the enclosing function to a generator function (`function*`) - - × A 'yield' expression is only allowed in a generator body. - ╭─[typescript/tests/cases/conformance/classes/awaitAndYieldInProperty.ts:7:28] - 6 │ [yield 1] = yield 2; - 7 │ static [yield 3] = yield 4; - · ───── - 8 │ } - ╰──── - help: Either remove this `yield` or change the enclosing function to a generator function (`function*`) - - × A 'yield' expression is only allowed in a generator body. - ╭─[typescript/tests/cases/conformance/classes/awaitAndYieldInProperty.ts:14:21] - 13 │ - 14 │ [yield 1] = yield 2; - · ───── - 15 │ static [yield 3] = yield 4; - ╰──── - help: Either remove this `yield` or change the enclosing function to a generator function (`function*`) - - × A 'yield' expression is only allowed in a generator body. - ╭─[typescript/tests/cases/conformance/classes/awaitAndYieldInProperty.ts:15:28] - 14 │ [yield 1] = yield 2; - 15 │ static [yield 3] = yield 4; - · ───── - 16 │ } - ╰──── - help: Either remove this `yield` or change the enclosing function to a generator function (`function*`) - × `await` is only allowed within async functions and at the top levels of modules ╭─[typescript/tests/cases/conformance/classes/awaitAndYieldInProperty.ts:3:21] 2 │ class C { @@ -12675,6 +12702,24 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Either remove this `await` or add the `async` keyword to the enclosing function + × A 'yield' expression is only allowed in a generator body. + ╭─[typescript/tests/cases/conformance/classes/awaitAndYieldInProperty.ts:6:21] + 5 │ + 6 │ [yield 1] = yield 2; + · ───── + 7 │ static [yield 3] = yield 4; + ╰──── + help: Either remove this `yield` or change the enclosing function to a generator function (`function*`) + + × A 'yield' expression is only allowed in a generator body. + ╭─[typescript/tests/cases/conformance/classes/awaitAndYieldInProperty.ts:7:28] + 6 │ [yield 1] = yield 2; + 7 │ static [yield 3] = yield 4; + · ───── + 8 │ } + ╰──── + help: Either remove this `yield` or change the enclosing function to a generator function (`function*`) + × `await` is only allowed within async functions and at the top levels of modules ╭─[typescript/tests/cases/conformance/classes/awaitAndYieldInProperty.ts:11:21] 10 │ return class { @@ -12693,6 +12738,24 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Either remove this `await` or add the `async` keyword to the enclosing function + × A 'yield' expression is only allowed in a generator body. + ╭─[typescript/tests/cases/conformance/classes/awaitAndYieldInProperty.ts:14:21] + 13 │ + 14 │ [yield 1] = yield 2; + · ───── + 15 │ static [yield 3] = yield 4; + ╰──── + help: Either remove this `yield` or change the enclosing function to a generator function (`function*`) + + × A 'yield' expression is only allowed in a generator body. + ╭─[typescript/tests/cases/conformance/classes/awaitAndYieldInProperty.ts:15:28] + 14 │ [yield 1] = yield 2; + 15 │ static [yield 3] = yield 4; + · ───── + 16 │ } + ╰──── + help: Either remove this `yield` or change the enclosing function to a generator function (`function*`) + × TS(1318): Accessor 'aa' cannot have an implementation because it is marked abstract. ╭─[typescript/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAccessor.ts:3:17] 2 │ abstract get a(); @@ -19784,23 +19847,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va · ───── ╰──── - × `await` is only allowed within async functions and at the top levels of modules - ╭─[typescript/tests/cases/conformance/externalModules/topLevelAwaitNonModule.ts:1:1] - 1 │ await x; - · ───── - 2 │ - ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function - - × `await` is only allowed within async functions and at the top levels of modules - ╭─[typescript/tests/cases/conformance/externalModules/topLevelAwaitNonModule.ts:5:5] - 4 │ - 5 │ for await (const item of arr) { - · ───── - 6 │ item; - ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function - × Expected `=` but found `;` ╭─[typescript/tests/cases/conformance/externalModules/typeOnly/exportDeclaration_missingBraces.ts:11:16] 10 │ namespace ns { @@ -24450,22 +24496,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── help: Wrap this declaration in a block statement - × Cannot assign to this expression - ╭─[typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.4.ts:2:5] - 1 │ { - 2 │ await using [a] = null; - · ─────────────── - 3 │ } - ╰──── - - × `await` is only allowed within async functions and at the top levels of modules - ╭─[typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.4.ts:2:5] + × Expected a semicolon or an implicit semicolon after a statement, but found none + ╭─[typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.4.ts:2:10] 1 │ { 2 │ await using [a] = null; - · ───── + · ▲ 3 │ } ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function + help: Try inserting a semicolon here × Using declarations may not have binding patterns. ╭─[typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.5.ts:3:17] @@ -24476,23 +24514,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va ╰──── × Expected a semicolon or an implicit semicolon after a statement, but found none - ╭─[typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.6.ts:2:16] + ╭─[typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.6.ts:2:10] 1 │ { 2 │ await using {a} = null; - · ▲ + · ▲ 3 │ } ╰──── help: Try inserting a semicolon here - × `await` is only allowed within async functions and at the top levels of modules - ╭─[typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.6.ts:2:5] - 1 │ { - 2 │ await using {a} = null; - · ───── - 3 │ } - ╰──── - help: Either remove this `await` or add the `async` keyword to the enclosing function - × Using declarations may not have binding patterns. ╭─[typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.7.ts:3:17] 2 │ await using a = null, diff --git a/tasks/coverage/snapshots/transformer_misc.snap b/tasks/coverage/snapshots/transformer_misc.snap index 56ef1c69aa893..7ccc8759d7902 100644 --- a/tasks/coverage/snapshots/transformer_misc.snap +++ b/tasks/coverage/snapshots/transformer_misc.snap @@ -1,5 +1,3 @@ transformer_misc Summary: AST Parsed : 64/64 (100.00%) -Positive Passed: 63/64 (98.44%) -Mismatch: tasks/coverage/misc/pass/babel-16776-s.js - +Positive Passed: 64/64 (100.00%)