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

Class Field Pass-through Parser

Build a small parsing utility that accepts JavaScript snippets containing public and private class members and returns the unmodified code plus a parsed AST. The pipeline must rely on a syntax-only plugin so no code transforms are emitted.

Capabilities

Parse public fields

  • Given a class with instance and static public fields initialized inline, parsing succeeds and the returned code string matches the input exactly. @test

Parse private members

  • Given a class using private fields and a private method, parsing succeeds without syntax errors and the returned code string matches the input. @test

Preserve source output

  • For any input string, the parser output must be identical to the input (no helper injections or property rewrites). @test

Implementation

@generates

Configure the parsing pipeline to enable class field syntax without registering any transform plugins or helpers.

API

export function parseClassFeatures(sourceCode);
  • sourceCode: a string of JavaScript containing potential class fields or private members.
  • Returns an object with ast (the parsed program) and code (the output source string after running through the pipeline). code must be exactly the same as the input.

Dependencies { .dependencies }

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

Enables parsing of class field syntax without applying transformations.

Install with Tessl CLI

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

tile.json