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-3/

ES2015 Computed Property Transpiler

A tool that transpiles JavaScript code containing ES2015 computed properties into ES5-compatible code.

Capabilities

Transform basic computed properties

  • Given an object with a single computed property { ["x" + foo]: "heh" }, it transpiles to ES5-compatible code @test
  • Given an object with multiple computed properties, it transpiles them correctly while maintaining property order @test

Handle mixed property types

  • Given an object with both regular and computed properties, it correctly preserves regular properties before the first computed property @test

Support transformation modes

  • When configured with loose mode, it uses simple property assignment @test

Implementation

@generates

API

/**
 * Transpiles JavaScript code containing computed properties to ES5.
 *
 * @param {string} code - The JavaScript code to transpile.
 * @param {object} options - Transformation options.
 * @param {boolean} options.loose - Use loose mode (simple assignment) instead of defineProperty.
 * @returns {string} The transpiled ES5-compatible code.
 */
function transpile(code, options = {}) {
  // IMPLEMENTATION HERE
}

module.exports = { transpile };

Dependencies { .dependencies }

@babel/plugin-transform-computed-properties { .dependency }

Provides computed property transformation functionality.

@satisfied-by

@babel/core { .dependency }

Provides Babel transformation infrastructure.

@satisfied-by

Install with Tessl CLI

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

tile.json