or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-8/

JSX Optional Access Resolver

A utility for statically resolving JSX attribute values that rely on optional chaining, optional function calls, and TypeScript assertions without executing user code.

Capabilities

Optional member chains

  • A JSX attribute containing settings?.theme ?? 'light' resolves to 'light' when settings is undefined in the provided attribute node. @test
  • A JSX attribute containing settings?.theme ?? 'light' resolves to 'dark' when settings is a literal object that includes { theme: 'dark' }. @test

Optional calls

  • A JSX attribute containing factory?.().mode || 'safe' resolves to 'fast' when the optional call returns { mode: 'fast' }. @test

TypeScript assertions

  • A JSX attribute containing (props!.palette as string).toUpperCase?.() resolves to 'ACCENT' when the literal palette value is 'accent'. @test

Implementation

@generates

API

/**
 * Resolves a JSX attribute's value into the closest runtime-equivalent value.
 * Should support optional member chains, optional calls, and TypeScript assertions/casts without throwing on unknown expressions.
 */
export function resolveAttributeValue(attribute: unknown): unknown;

/**
 * Resolves only literal-friendly JSX attribute values.
 * Complex expressions (including optional chains) should return undefined, null, or primitive values when they can be determined safely.
 */
export function resolveLiteralAttributeValue(attribute: unknown): string | number | boolean | null | undefined;

Dependencies { .dependencies }

jsx-ast-utils { .dependency }

Use utilities for interpreting JSX attribute AST nodes, including optional chaining and TypeScript assertions.

@satisfied-by