Skip to content

Commit

Permalink
fix(transformer): TODO comments for missing scopes (#3837)
Browse files Browse the repository at this point in the history
Where we create new block statements, need to generate scopes for them. Just adding TODO comments for this at present - we need an API to make this easy.
  • Loading branch information
overlookmotel committed Jun 23, 2024
1 parent d9f268d commit d76f34b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/oxc_transformer/src/typescript/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ impl<'a> TypeScriptAnnotations<'a> {
if !self.assignments.is_empty() {
if let Statement::ExpressionStatement(expr) = &stmt.consequent {
if expr.expression.is_super_call_expression() {
// TODO: Need to create a scope for this block
stmt.consequent = self.ctx.ast.block_statement(self.ctx.ast.block(
expr.span,
self.ctx.ast.new_vec_single(self.ctx.ast.copy(&stmt.consequent)),
Expand All @@ -386,13 +387,15 @@ impl<'a> TypeScriptAnnotations<'a> {
};
if let Some(span) = alternate_span {
let alternate = stmt.alternate.take().unwrap();
// TODO: Need to create a scope for this block
stmt.alternate = Some(self.ctx.ast.block_statement(
self.ctx.ast.block(span, self.ctx.ast.new_vec_single(alternate)),
));
}
}

if stmt.consequent.is_typescript_syntax() {
// TODO: Need to create a scope for this block
stmt.consequent = self.ctx.ast.block_statement(
self.ctx.ast.block(stmt.consequent.span(), self.ctx.ast.new_vec()),
);
Expand All @@ -405,6 +408,7 @@ impl<'a> TypeScriptAnnotations<'a> {

pub fn transform_for_statement(&mut self, stmt: &mut ForStatement<'a>) {
if stmt.body.is_typescript_syntax() {
// TODO: Need to create a scope for this block
stmt.body = self
.ctx
.ast
Expand All @@ -414,6 +418,7 @@ impl<'a> TypeScriptAnnotations<'a> {

pub fn transform_while_statement(&mut self, stmt: &mut WhileStatement<'a>) {
if stmt.body.is_typescript_syntax() {
// TODO: Need to create a scope for this block
stmt.body = self
.ctx
.ast
Expand All @@ -423,6 +428,7 @@ impl<'a> TypeScriptAnnotations<'a> {

pub fn transform_do_while_statement(&mut self, stmt: &mut DoWhileStatement<'a>) {
if stmt.body.is_typescript_syntax() {
// TODO: Need to create a scope for this block
stmt.body = self
.ctx
.ast
Expand Down

0 comments on commit d76f34b

Please sign in to comment.