Type.FunctionReturn
TypeReturns the return type declared for a given function type.
Syntax
Type.FunctionReturn(type as type) as typeParameters
| Name | Type | Required | Description |
|---|---|---|---|
type | type | Yes | A function type whose return type is returned. |
Return Value
type — The declared return type of the function type.
Remarks
Type.FunctionReturn extracts the declared return type from a function type. When a function type explicitly declares its return type (e.g., type function (x as number) as text), this function returns that declared type. When no return type is declared, or when the return type is any, the result is type any.
This function operates on a function type value — not a function value directly. To get the type of an existing function, pass it through Value.Type(fn) first, then call Type.FunctionReturn on the result.
Type.FunctionReturn is used alongside Type.FunctionParameters for runtime signature inspection. Typical use cases include:
- Documentation generators that describe what a function produces - Generic pipelines that need to validate or adapt based on a function's output type - Custom connector development where function return types are declared programmatically
Most built-in Power Query functions declare nullable return types (e.g., type nullable number) because they can return null when inputs are null.
Examples
Example 1: Return type of a typed function literal
let
FType = type function (x as number) as text
in
Type.FunctionReturn(FType)Result | |
|---|---|
| 1 | type text |
Example 2: Return type of a built-in function
Result | |
|---|---|
| 1 | type nullable number |
Example 3: Undeclared return type produces type any
let
FType = type function (x as number) as any
in
Type.FunctionReturn(FType)Result | |
|---|---|
| 1 | type any |