From e219ae8c94af32c5a754eee1b082a38e7f095287 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:17:21 +0000 Subject: [PATCH] docs(transformer/nullish-coalescing): clarify doc comment (#7268) Expand doc comment for `create_conditional_expression` to clarify what it does. --- .../src/es2020/nullish_coalescing_operator.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/oxc_transformer/src/es2020/nullish_coalescing_operator.rs b/crates/oxc_transformer/src/es2020/nullish_coalescing_operator.rs index 2224b94d28c7b..0c2090e1d4d81 100644 --- a/crates/oxc_transformer/src/es2020/nullish_coalescing_operator.rs +++ b/crates/oxc_transformer/src/es2020/nullish_coalescing_operator.rs @@ -150,18 +150,25 @@ impl<'a, 'ctx> NullishCoalescingOperator<'a, 'ctx> { } } - /// Create a conditional expression + /// Create a conditional expression. /// /// ```js /// // Input - /// bar ?? "qux" + /// foo = bar ?? "qux" /// /// // Output - /// qux = bar !== null && bar !== void 0 ? bar : "qux" - /// // ^^^ assignment ^^^ reference ^^^ default + /// foo = bar !== null && bar !== void 0 ? bar : "qux" + /// // ^^^ assignment ^^^ reference ^^^^^ default /// ``` /// - /// reference and assignment are the same in this case, but they can be different + /// ```js + /// // Input + /// foo = bar.x ?? "qux" + /// + /// // Output + /// foo = (_bar$x = bar.x) !== null && _bar$x !== void 0 ? _bar$x : "qux" + /// // ^^^^^^^^^^^^^^^^ assignment ^^^^^^ reference ^^^^^ default + /// ``` fn create_conditional_expression( reference: Expression<'a>, assignment: Expression<'a>,