Skip to content

MemberDeclaration

Declares a symbol in the current member scope for this component’s children.

Overload 1

Create a member declaration by providing a symbol name and optional symbol metadata.

import { MemberDeclaration } from "@alloy-js/core";
<MemberDeclaration
metadata={Record<string, unknown>}
name="string"
refkey={Refkey | Refkey[]}
static
>
{children}
</MemberDeclaration>

Props

childrenoptionalChildren
metadataoptionalRecord<string, unknown>

Additional metadata for the declared symbol.

namestring

The name of this declaration.

refkeyoptionalRefkey | Refkey[]

The refkey or array refkeys for this declaration.

staticoptionalboolean

Whether this is a static member. If not provided, the member is an instance member.

Overload 2

Create a declaration by providing an already created symbol. The symbol is merely exposed via Declaration context.

import { MemberDeclaration } from "@alloy-js/core";
<MemberDeclaration symbol={OutputSymbol}>
{children}
</MemberDeclaration>

Props

childrenoptionalChildren
symbolDeclaration context interface

The symbol being declared. When provided, the name, refkey, and metadata props are ignored.

Remarks

This component must be called in one of two ways: with a name and an optional refkey, or else passing in the symbol. When called with a name and refkey, a symbol will be created in the current scope (provided by MemberDeclaration context) with that name and refkey. If a refkey is not provided, refkey(props.name) is used.

When called with a symbol, that symbol is merely exposed via MemberDeclaration context. It is assumed that the caller of this component has created the symbol with the createSymbol API on the Binder context.

See also