createAccessExpression
Create a language-specific access/member expression component pair.
Returns { Expression, Part } where:
Expressionis the main component that collects Part children and renders the chainPartis a no-op component whose props are consumed by Expression
The factory handles:
- Children collection and Part filtering
- Symbol resolution (refkey → symbol via binder, single computed per part)
- Reactive optimization (getter delegation over single computed per part)
- Flattening nested Expression instances
takeSymbols()to prevent symbol leakage- Call chain detection and chunked formatting algorithm
Configuration for creating a language-specific access expression component.
import { createAccessExpression } from "@alloy-js/core";
<createAccessExpression />import { createAccessExpression } from "@alloy-js/core/stc";
createAccessExpression({ canUseCallChains: undefined, createDescriptor: undefined, formatPart: undefined, getBase: undefined, isCallPart: undefined, wrapPartResult: undefined,}).children(children)| canUseCallChains | (TPart[]) => boolean | Additional check for whether call chain formatting should be used.
Called only when |
| createDescriptor | (TPartProps, OutputSymbol | undefined, boolean) => TPart | Convert Part props + resolved symbol into a plain descriptor object. Called once per Part during children processing. The returned descriptor is wrapped in a computed + getter delegation for reactive optimization. |
| formatPart | (TPart, TPart, boolean) => Children | Format a non-first part given its descriptor and the previous part.
Returns JSX children for that segment (e.g., |
| getBase | (TPart) => Children | Extract the base content from the first part (the leftmost identifier). |
| isCallPart | (TPart) => boolean | Identify which parts are function calls, for call chain detection. When provided, the factory uses the chunked call chain algorithm (line breaks after each call group) when more than one call is detected. When omitted, the expression is always formatted linearly. |
| wrapPartResult | (Children, TPart, number, boolean) => Children | Post-process the accumulated expression after each part in linear
(non-call-chain) mode. Use this for language-specific wrapping like
TypeScript’s |