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
4 changes: 4 additions & 0 deletions crates/oxc_semantic/src/checker/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,10 @@ pub fn check_variable_declaration(decl: &VariableDeclaration, ctx: &SemanticBuil
{
ctx.error(diagnostics::using_declaration_not_allowed_in_script(decl.span));
}
if decl.kind.is_await() && ctx.scoping.scope_flags(ctx.current_scope_id).is_class_static_block()
{
ctx.error(diagnostics::class_static_block_await_using(decl.span));
}
}

pub fn check_meta_property(prop: &MetaProperty, ctx: &SemanticBuilder<'_>) {
Expand Down
6 changes: 6 additions & 0 deletions crates/oxc_semantic/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ pub fn class_static_block_for_await(span: Span) -> OxcDiagnostic {
.with_label(span)
}

#[cold]
pub fn class_static_block_await_using(span: Span) -> OxcDiagnostic {
OxcDiagnostic::error("Cannot use 'await using' in class static initialization block")
.with_label(span)
}

#[cold]
pub fn reserved_keyword(x0: &str, span1: Span) -> OxcDiagnostic {
OxcDiagnostic::error(format!("The keyword '{x0}' is reserved")).with_label(span1)
Expand Down
12 changes: 9 additions & 3 deletions tasks/coverage/snapshots/parser_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ commit: c9e7428b
parser_typescript Summary:
AST Parsed : 9828/9831 (99.97%)
Positive Passed: 9817/9831 (99.86%)
Negative Passed: 1533/2587 (59.26%)
Negative Passed: 1534/2587 (59.30%)
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/FunctionDeclaration3.ts

Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/FunctionDeclaration4.ts
Expand Down Expand Up @@ -1966,8 +1966,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/scanner/e

Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral9.ts

Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.14.ts

Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.4.ts

Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts
Expand Down Expand Up @@ -25876,6 +25874,14 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
╰────
help: Wrap this code in a block or use a module

× Cannot use 'await using' in class static initialization block
╭─[typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.14.ts:3:9]
2 │ static {
3 │ await using x = null;
· ─────────────────────
4 │ {
╰────

× TS(1546): 'await using' declarations are not allowed in ambient contexts.
╭─[typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.16.ts:2:17]
1 │ declare namespace N {
Expand Down
Loading