FunctionType
A TypeScript function declaration.
Options for [unresolved link] component.
import { FunctionType } from "@alloy-js/typescript";
<FunctionType async doc={Children} parameters={ParameterDescriptor[] | string[]} parametersChildren={Children} returnType={Children} typeParameters={TypeParameterDescriptor[] | string[]} typeParametersChildren={Children}> {children}</FunctionType>
import { FunctionType } from "@alloy-js/typescript/stc";
FunctionType({ async: boolean, doc: Children, parameters: ParameterDescriptor[] | string[], parametersChildren: Children, returnType: Children, typeParameters: TypeParameterDescriptor[] | string[], typeParametersChildren: Children,}).children(children)
Props
async | optionalboolean If the method is async |
children | optionalChildren Jsx content |
doc | optionalChildren Documentation for this method. |
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. |
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 TypeParameterDescriptors or TypeParameterDescriptors.
- As raw content via the
parametersChildren
ortypeParametersChildren
props. - As a child of this component via the [unresolved link] or [unresolved link] components.
Example
(foo: string, bar: number) => void