Skip to content

Commit c743c73

Browse files
committed
fixup: literal object keys work
1 parent 862bfdf commit c743c73

File tree

1 file changed

+6
-3
lines changed
  • packages/async-rewriter3/src

1 file changed

+6
-3
lines changed

packages/async-rewriter3/src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{borrow::Borrow, collections::VecDeque, fmt::Debug};
22
use wasm_bindgen::prelude::*;
3-
use rslint_parser::{ast::{ArrowExpr, AssignExpr, CallExpr, ClassDecl, Constructor, Expr, ExprOrBlock, ExprStmt, FnDecl, FnExpr, Method, NameRef, ObjectPatternProp, ParameterList, Pattern, PropName, ReturnStmt, ThisExpr, UnaryExpr, VarDecl}, parse_text, AstNode, SyntaxNode, TextSize};
3+
use rslint_parser::{ast::{ArrowExpr, AssignExpr, CallExpr, ClassDecl, Constructor, Expr, ExprOrBlock, ExprStmt, FnDecl, FnExpr, Literal, Method, NameRef, ObjectPatternProp, ParameterList, Pattern, PropName, ReturnStmt, ThisExpr, UnaryExpr, VarDecl}, parse_text, AstNode, SyntaxNode, TextSize};
44

55
#[derive(Debug)]
66
enum InsertionText {
@@ -363,14 +363,17 @@ fn collect_insertions(node: &SyntaxNode, nesting_depth: u32) -> InsertionList {
363363
as_expr.syntax().text_range()) ||
364364
(is_unary_rhs && !is_typeof_rhs);
365365
let is_argument_default_value = ParameterList::can_cast(as_expr.syntax().parent().unwrap().parent().unwrap().kind());
366+
let is_literal = Literal::can_cast(as_expr.syntax().kind());
367+
let wants_implicit_await_wrapper = !is_lhs_of_assign_expr && !is_argument_default_value && !is_eval_this_super_reference && !is_literal;
366368

367369
if is_named_typeof_rhs {
368370
insertions.push_back(Insertion::new_dynamic(as_expr.syntax().parent().unwrap().text_range().start(), [
369371
"(typeof ", as_expr.syntax().text().to_string().as_str(), " === 'undefined' ? 'undefined' : "
370372
].concat()));
371373
pushed_insertions += 1;
372374
}
373-
if !is_lhs_of_assign_expr && !is_argument_default_value && !is_eval_this_super_reference {
375+
376+
if wants_implicit_await_wrapper {
374377
insertions.push_back(Insertion::new(range.start(), "(_ex = "));
375378
pushed_insertions += 1;
376379
}
@@ -410,7 +413,7 @@ fn collect_insertions(node: &SyntaxNode, nesting_depth: u32) -> InsertionList {
410413
insertions.append(child_insertions);
411414
},
412415
}
413-
if !is_dot_call_expression && !is_lhs_of_assign_expr && !is_argument_default_value && !is_eval_this_super_reference {
416+
if wants_implicit_await_wrapper && !is_dot_call_expression {
414417
insertions.push_back(Insertion::new(range.end(), ", _isp(_ex) ? await _ex : _ex)"));
415418
}
416419
if is_named_typeof_rhs {

0 commit comments

Comments
 (0)