or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-6/

Literal Prop Report

Builds a helper that inspects a JSX opening element node and returns a plain object of props whose values are purely literal.

Capabilities

Extracts primitive props

  • Given a JSX opening element for <Button label="Click" size={12} disabled>, returns { label: "Click", size: 12, disabled: true } with keys matching attribute names. @test
  • When a prop explicitly uses null or undefined, include it as the value rather than omitting. Example <Item note={null} flag={undefined}> yields { note: null, flag: undefined }. @test

Filters non-literal values

  • For <Card onSelect={() => pick()} title="View" data={user}> only include the literal entries, resulting in { title: "View" }, and skip props whose values are functions, identifiers, JSX elements, or other expressions. @test

Trims arrays to literal entries

  • For <List values={["a", 2, otherVar, () => 3, false]} tag="ok"> include only the literal array items, resulting in { values: ["a", 2, false], tag: "ok" }. @test
  • If an array prop contains no literal items (e.g., <List values={[handler, ref]}>), omit that prop from the output entirely. @test

Implementation

@generates

API

export function extractLiteralProps(openingElementNode);

Accepts a JSXOpeningElement AST node and returns a plain object mapping attribute names (including namespaces and hyphenated names) to their literal values. Boolean-style attributes without an explicit value must be treated as true. Props with non-literal values are skipped unless an array contains at least one literal entry, in which case only the literal elements are preserved. Props omitted due to non-literal or empty literal results must not appear as keys in the returned object.

Dependencies { .dependencies }

jsx-ast-utils { .dependency }

Utilities for inspecting JSX AST nodes to read prop names and literal-safe values. @satisfied-by