Skip to content

Commit

Permalink
feat(transformer/nullish-coalescing-operator): add comments in top of…
Browse files Browse the repository at this point in the history
… file
  • Loading branch information
Dunqing committed Aug 19, 2024
1 parent 53f0be6 commit b30ec72
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions crates/oxc_transformer/src/es2020/nullish_coalescing_operator.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
//! [plugin-nullish-coalescing-operator](https://babeljs.io/docs/babel-plugin-transform-nullish-coalescing-operator)
//!
//! This plugin transforms nullish coalescing operators (`??`) to a series of ternary expressions.
//!
//! > This plugin is included in `preset-env`, in ES2020
//!
//! ## Example
//!
//! ```js
//! // Input
//! var foo = object.foo ?? "default";
//!
//! // Output
//! var _object$foo;
//! var foo =
//! (_object$foo = object.foo) !== null && _object$foo !== void 0
//! ? _object$foo
//! : "default";
//! ```
//!
//! ## References:
//! * <https://babeljs.io/docs/babel-plugin-transform-nullish-coalescing-operator> Babel documentation
//! * <https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-nullish-coalescing-operator> Babel plugin implementation
//! * <https://github.com/tc39-transfer/proposal-nullish-coalescing> Nullish coalescing proposal
use std::cell::Cell;

use oxc_semantic::{ReferenceFlag, SymbolFlags};
Expand All @@ -10,11 +35,6 @@ use oxc_syntax::operator::{AssignmentOperator, BinaryOperator, LogicalOperator};

use crate::context::Ctx;

/// ES2020: Nullish Coalescing Operator
///
/// References:
/// * <https://babeljs.io/docs/babel-plugin-transform-nullish-coalescing-operator>
/// * <https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-nullish-coalescing-operator>
pub struct NullishCoalescingOperator<'a> {
_ctx: Ctx<'a>,
var_declarations: std::vec::Vec<Vec<'a, VariableDeclarator<'a>>>,
Expand Down

0 comments on commit b30ec72

Please sign in to comment.