CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel-plugin-transform-es2015-computed-properties

Babel plugin that compiles ES2015 computed properties to ES5-compatible code

88

1.07x
Overview
Eval results
Files

task.mdevals/scenario-6/

Dynamic Property Configuration System

Build a Babel plugin that transforms objects with computed method properties into ES5-compatible code. Your plugin should handle object methods defined with computed property names (e.g., [methodName]() { ... }) and convert them appropriately for older JavaScript environments.

Requirements

Your Babel plugin must transform object expressions that contain methods with computed property names. The transformation should:

  1. Detect object methods that use computed property syntax
  2. Convert these methods into function expressions
  3. Properly assign the function expressions to the computed property keys
  4. Preserve method characteristics such as async and generator function modifiers
  5. Handle objects that mix computed methods with regular properties

Test Cases

  • Transforms a simple computed method into a function expression and property assignment @test
  • Preserves async function modifier when transforming async computed methods @test
  • Preserves generator function modifier when transforming generator computed methods @test
  • Handles objects with multiple computed methods @test

Implementation

@generates

API

/**
 * Babel plugin that transforms computed method properties
 * @returns {object} Babel plugin object with visitor methods
 */
function transformComputedMethods() {
  // Implementation here
}

module.exports = transformComputedMethods;

Dependencies { .dependencies }

@babel/core { .dependency }

Provides the Babel transformation framework and AST node types.

@babel/helper-plugin-test-runner { .dependency }

Testing utilities for Babel plugins.

Install with Tessl CLI

npx tessl i tessl/npm-babel-plugin-transform-es2015-computed-properties

tile.json