Dunqing 2024-01-06 12:56:27 +08:00 committed by GitHub
parent b0569bc8e7
commit 3b4fe0edfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 16 deletions

View file

@ -179,6 +179,10 @@ pub const STRICT_MODE_NAMES: Set<&'static str> = phf_set! {
};
fn check_identifier<'a>(name: &Atom, span: Span, node: &AstNode<'a>, ctx: &SemanticBuilder<'a>) {
// ts module block allows revered keywords
if ctx.current_scope_flags().is_ts_module_block() {
return;
}
if *name == "await" {
// It is a Syntax Error if the goal symbol of the syntactic grammar is Module and the StringValue of IdentifierName is "await".
if ctx.source_type.is_module() {

View file

@ -52,6 +52,10 @@ impl ScopeFlags {
self.contains(Self::ClassStaticBlock)
}
pub fn is_ts_module_block(&self) -> bool {
self.contains(Self::TsModuleBlock)
}
pub fn is_var(&self) -> bool {
self.intersects(Self::Var)
}

View file

@ -3955,14 +3955,6 @@ Expect to Parse: "conformance/externalModules/topLevelAwait.2.ts"
· ─────
╰────
× The keyword 'await' is reserved
╭─[conformance/externalModules/topLevelAwait.2.ts:3:1]
3 │
4 │ declare namespace foo { const await: any; }
· ─────
5 │
╰────
× The keyword 'await' is reserved
╭─[conformance/externalModules/topLevelAwait.2.ts:6:1]
6 │ // await allowed in import=namespace when not a module
@ -15634,14 +15626,6 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts"
· ─────
╰────
× The keyword 'await' is reserved
╭─[conformance/externalModules/topLevelAwaitErrors.12.ts:4:1]
4 │ export {};
5 │ declare namespace foo { const await: any; }
· ─────
6 │
╰────
× The keyword 'await' is reserved
╭─[conformance/externalModules/topLevelAwaitErrors.12.ts:7:1]
7 │ // await disallowed in import=namespace when in a module