Babel plugin that compiles ES2015 computed properties to ES5-compatible code
88
Build a Babel plugin helper that generates unique temporary variable names for object literal transformations, avoiding conflicts with existing variables in the current scope.
When transforming object literals with computed properties in Babel, you often need to create temporary variables to hold the object being constructed. This utility should generate these temporary variable names intelligently by:
@generates
/**
* Generates a unique temporary variable name for an object literal node
* @param {Object} node - Babel AST node (ObjectExpression)
* @param {Object} scope - Babel Scope object for checking existing bindings
* @returns {string} A unique variable name (e.g., "_obj", "_obj2", "_obj3")
*/
function generateTempVarName(node, scope) {
// Implementation here
}
module.exports = { generateTempVarName };Provides examples and patterns for scope-aware variable generation when transforming computed properties.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-babel-plugin-transform-es2015-computed-propertiesdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10