CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel--plugin-syntax-class-properties

Babel syntax plugin that enables parsing of class properties, private properties, and private methods

94

1.04x
Overview
Eval results
Files

task.mdevals/scenario-5/

Class Field Syntax Safeguard

Build a Babel helper that guarantees code containing public and private class fields can be parsed while leaving the emitted code unchanged when class field syntax is already supported elsewhere in the config.

Capabilities

Passes through when supported

  • Transforming code that includes public and private class fields with a config that already supports class fields returns the same code (ignoring trailing newlines). @test

Idempotent plugin wiring

  • If the base config already lists the class field syntax plugin, ensuring syntax support does not duplicate the entry but still compiles successfully. @test

Adds syntax support when missing

  • When the base config lacks class field syntax support, the helper injects it so transforming class field code succeeds without altering the code. @test

Implementation

@generates

API

/**
 * Returns a Babel config that guarantees class field syntax is parseable.
 * Behaves as a no-op when class field syntax is already enabled.
 * @param {import('@babel/core').TransformOptions} baseConfig
 * @returns {import('@babel/core').TransformOptions}
 */
export function ensureClassFieldSyntax(baseConfig);

/**
 * Transforms source using the safeguarded config and returns the resulting code string.
 * @param {string} source
 * @param {import('@babel/core').TransformOptions} baseConfig
 * @returns {Promise<string>}
 */
export async function transformWithClassFields(source, baseConfig);

Dependencies { .dependencies }

@babel/core { .dependency }

Runs code transforms with the safeguarded configuration.

@babel/plugin-syntax-class-properties { .dependency }

Enables parsing for class fields and should act as a no-op when that syntax is already enabled.

Install with Tessl CLI

npx tessl i tessl/npm-babel--plugin-syntax-class-properties

tile.json