or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-5/

JSX Prop Value Normalizer

Transform parsed JSX attribute nodes into serializable shapes that preserve how arrays, objects, and callable constructs appear in the original JSX.

Capabilities

Reconstructs collection expressions

  • A settings attribute set to { layout: "grid", ...preset, meta: { active: true, ...extras }, tags: ["a", ...labels, "z"] } returns a shape { name: "settings", value: { layout: "grid", meta: { active: true }, tags: ["a", undefined, "z"] } }, treating unknown object spreads as empty objects and unknown array spreads as undefined slots while keeping literal members intact and in order. @test
  • Nested literals stay intact: { config: { limits: { retries: 3 }, path: ["/home", null, 9] } } yields { name: "config", value: { limits: { retries: 3 }, path: ["/home", null, 9] } } with the same nesting depth and primitive values. @test

Represents callable constructions

  • A bind expression prop (e.g., action={::this.handleClick} or action={foo::bar}) returns the string form of the bind call such as "this.handleClick.bind(this)" or "bar.bind(foo)" while retaining other props untouched. @test
  • A prop set via a new expression (e.g., connection={new Client('abc')}) yields an empty object {} for that value, and any literal siblings inside arrays or objects around it remain preserved. @test

Implementation

@generates

API

export interface PropShape {
  /** Attribute name */
  name: string;
  /** Reconstructed value from the JSX attribute */
  value: any;
}

/**
 * Converts JSXAttribute nodes into named shapes, reconstructing
 * array/object expressions (including spreads), bind expressions, and new expressions.
 */
export function extractPropShapes(attributes: any[]): PropShape[];

Dependencies { .dependencies }

jsx-ast-utils { .dependency }

Utilities for reading JSX attribute names and reconstructing prop values from AST nodes.