mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 04:42:10 +00:00
docs(transformer/nullish-coalescing): clarify doc comment (#7268)
Expand doc comment for `create_conditional_expression` to clarify what it does.
This commit is contained in:
parent
a48ebd6295
commit
e219ae8c94
1 changed files with 12 additions and 5 deletions
|
|
@ -150,18 +150,25 @@ impl<'a, 'ctx> NullishCoalescingOperator<'a, 'ctx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a conditional expression
|
/// Create a conditional expression.
|
||||||
///
|
///
|
||||||
/// ```js
|
/// ```js
|
||||||
/// // Input
|
/// // Input
|
||||||
/// bar ?? "qux"
|
/// foo = bar ?? "qux"
|
||||||
///
|
///
|
||||||
/// // Output
|
/// // Output
|
||||||
/// qux = bar !== null && bar !== void 0 ? bar : "qux"
|
/// foo = bar !== null && bar !== void 0 ? bar : "qux"
|
||||||
/// // ^^^ assignment ^^^ reference ^^^ default
|
/// // ^^^ 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(
|
fn create_conditional_expression(
|
||||||
reference: Expression<'a>,
|
reference: Expression<'a>,
|
||||||
assignment: Expression<'a>,
|
assignment: Expression<'a>,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue