FunctionDeclaration
A TypeScript function declaration.
import { FunctionDeclaration } from "@alloy-js/typescript";
<FunctionDeclaration async default doc={Children} export flags={OutputSymbolFlags} kind={"type" | "value"} metadata={Record<string, unknown>} name="string" parameters={ParameterDescriptor[] | string[]} parametersChildren={Children} refkey={Refkey | Refkey[]} returnType={Children} typeParameters={TypeParameterDescriptor[] | string[]} typeParametersChildren={Children}> {children}</FunctionDeclaration>
import { FunctionDeclaration } from "@alloy-js/typescript/stc";
FunctionDeclaration({ async: boolean, default: boolean, doc: Children, export: boolean, flags: OutputSymbolFlags, kind: "type" | "value", metadata: Record<string, unknown>, name: string, parameters: ParameterDescriptor[] | string[], parametersChildren: Children, refkey: Refkey | Refkey[], returnType: Children, typeParameters: TypeParameterDescriptor[] | string[], typeParametersChildren: Children,}).children(children)
Props
async | optionalboolean |
children | optionalChildren |
children | optionalChildren |
default | optionalboolean Whether this is the default export of the module. |
doc | optionalChildren Documentation for this declaration |
export | optionalboolean Whether to export this declaration from the module. |
flags | optionalOutputSymbolFlags Flags for the symbol created by this component. |
kind | optional”type” | “value” Whether this is a declaration of a type (e.g. interface, type alias) or a value (e.g. var, const, let). |
metadata | optionalRecord<string, unknown> Arbitrary metadata about this declaration. |
name | string The base name of this declaration. May change depending on naming policy and any conflicts. |
parameters | optionalParameterDescriptor[] | string[] The parameters to the function. Can be an array of strings for parameters which don’t have a type or a default value. Otherwise, it’s an array of ParameterDescriptors. |
parametersChildren | optionalChildren Raw content to be used as the parameter list. |
refkey | optionalRefkey | Refkey[] The refkey or array of refkeys for this declaration. |
returnType | optionalChildren The return type of the function. |
typeParameters | optionalTypeParameterDescriptor[] | string[] The type parameters for the function. Can be an array of strings for type parameters which don’t have any constraints or a default type, otherwise it’s an array of TypeParameterDescriptors. |
typeParametersChildren | optionalChildren Raw content to be used as the type parameter list. |
Remarks
Providing parameters and type parameters can be accomplished in one of three ways:
- As an array of ParameterDescriptors or TypeParameterDescriptors.
- As raw content via the
parametersChildren
ortypeParametersChildren
props. - As a child of this component via the [unresolved link] or [unresolved link] components.