Babel syntax plugin that enables parsing of class properties, private properties, and private methods
94
Build a parsing helper that accepts JavaScript source containing private class fields and methods and returns a summary of those members without transforming the code.
#count and private method #inc() is parsed without error, returning privateMembers entries for both with static: false and correct kinds. @test#registry and static private method #touch() is parsed without error, returning entries marked static: true for both members. @test#secret outside any class body raises a syntax error that includes the private name in the error message. @test@generates
export function parseWithPrivateMembers(
source: string,
options?: { filename?: string }
): {
ast: object;
privateMembers: Array<{ name: string; kind: 'field' | 'method'; static: boolean }>;
};Parses JavaScript into an AST using configurable syntax plugins.
@satisfied-by
Enables parsing of inline class fields, including private ones, without emitting transformations.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-babel--plugin-syntax-class-properties