@@ -3639,7 +3639,15 @@ fn gen_property_signature<'a>(node: &TsPropertySignature<'a>, context: &mut Cont
36393639fn gen_quotable_prop < ' a > ( node : Node < ' a > , context : & mut Context < ' a > ) -> PrintItems {
36403640 match context. config . quote_props {
36413641 QuoteProps :: AsNeeded => match node {
3642- Node :: Str ( str_lit) if is_text_valid_identifier ( str_lit. value ( ) ) => gen_from_raw_string ( str_lit. value ( ) ) ,
3642+ Node :: Str ( str_lit) => {
3643+ if let Some ( text) = str_lit. value ( ) . as_str ( )
3644+ && is_text_valid_identifier ( text)
3645+ {
3646+ gen_from_raw_string ( text)
3647+ } else {
3648+ gen_node ( node, context)
3649+ }
3650+ }
36433651 _ => gen_node ( node, context) ,
36443652 } ,
36453653 QuoteProps :: Consistent => match context. use_consistent_quote_props ( ) {
@@ -3651,7 +3659,10 @@ fn gen_quotable_prop<'a>(node: Node<'a>, context: &mut Context<'a>) -> PrintItem
36513659 } ,
36523660 Some ( false ) => match node {
36533661 // remove quotes
3654- Node :: Str ( str_lit) => gen_from_raw_string ( str_lit. value ( ) ) ,
3662+ Node :: Str ( str_lit) => match str_lit. value ( ) . as_str ( ) {
3663+ Some ( text) => gen_from_raw_string ( text) ,
3664+ None => gen_node ( node, context) ,
3665+ } ,
36553666 _ => gen_node ( node, context) ,
36563667 } ,
36573668 None => {
@@ -3698,15 +3709,21 @@ fn use_consistent_quotes_for_members<'a>(mut members: impl Iterator<Item = Node<
36983709 fn check_expr ( expr : Expr ) -> bool {
36993710 match expr {
37003711 Expr :: Ident ( ident) => !is_text_valid_identifier ( ident. sym ( ) ) ,
3701- Expr :: Lit ( Lit :: Str ( str) ) => !is_text_valid_identifier ( str. value ( ) ) ,
3712+ Expr :: Lit ( Lit :: Str ( str) ) => match str. value ( ) . as_str ( ) {
3713+ Some ( text) => !is_text_valid_identifier ( text) ,
3714+ None => true ,
3715+ } ,
37023716 _ => false ,
37033717 }
37043718 }
37053719
37063720 fn check_prop_name ( name : PropName ) -> bool {
37073721 match name {
37083722 PropName :: Ident ( ident) => !is_text_valid_identifier ( ident. sym ( ) ) ,
3709- PropName :: Str ( str) => !is_text_valid_identifier ( str. value ( ) ) ,
3723+ PropName :: Str ( str) => match str. value ( ) . as_str ( ) {
3724+ Some ( text) => !is_text_valid_identifier ( text) ,
3725+ None => true ,
3726+ } ,
37103727 _ => false ,
37113728 }
37123729 }
@@ -9117,7 +9134,7 @@ fn gen_jsx_children<'a>(opts: GenJsxChildrenOptions<'a>, context: &mut Context<'
91179134 let mut found_non_space_child = false ; // include space expressions at the start
91189135
91199136 for child in real_children. into_iter ( ) {
9120- if found_non_space_child && node_helpers:: has_jsx_space_expr_text ( child) {
9137+ if found_non_space_child && node_helpers:: has_jsx_space_expr_text ( child, context . program ) {
91219138 current_jsx_space_exprs. push ( child) ;
91229139 continue ;
91239140 }
@@ -9239,19 +9256,19 @@ fn gen_jsx_children<'a>(opts: GenJsxChildrenOptions<'a>, context: &mut Context<'
92399256
92409257 /// If the node has a "JSX space expression" between or text that's only spaces between.
92419258 fn has_jsx_space_between < ' a > ( previous_node : Node < ' a > , next_node : Node < ' a > , program : Program < ' a > ) -> bool {
9242- return node_helpers:: nodes_have_only_spaces_between ( previous_node, next_node, program) || has_jsx_space_expr_between ( previous_node, next_node) ;
9243-
9244- fn has_jsx_space_expr_between ( previous_node : Node , next_node : Node ) -> bool {
9259+ fn has_jsx_space_expr_between ( previous_node : Node , next_node : Node , program : Program ) -> bool {
92459260 let nodes_between = node_helpers:: get_siblings_between ( previous_node, next_node) ;
92469261
92479262 for node_between in nodes_between {
9248- if node_helpers:: has_jsx_space_expr_text ( node_between) {
9263+ if node_helpers:: has_jsx_space_expr_text ( node_between, program ) {
92499264 return true ;
92509265 }
92519266 }
92529267
92539268 false
92549269 }
9270+
9271+ node_helpers:: nodes_have_only_spaces_between ( previous_node, next_node, program) || has_jsx_space_expr_between ( previous_node, next_node, program)
92559272 }
92569273}
92579274
0 commit comments