---
title: "Return(): function in Authoring, TypeShade API reference"
description: "Return, a function in Authoring. Push an explicit return value; onto the innermost scope."
url: https://typeshade.dev/api/return/
language: en
---

# `Return()`

Function in Authoring

Push an explicit return value; onto the innermost scope.

`import { Return } from 'typeshade/core/ir'`

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
const Return: (value?: ReadonlyNode) => void
```

## Parameters

**`value` optional `ReadonlyNode`**

## Return value

`void`

## Description

Use it for any return from inside `If`, `Loop` or `Switch` control flow: a native JavaScript `return` inside a nested body callback only exits that closure and emits nothing, so what reads as an early exit falls through. The one place a native `return value` works is a body’s own final, top-level return, which `fn()` appends for you. For the common “return early if a condition holds” shape, [`ReturnIf`](https://typeshade.dev/api/returnif/) is the more readable guard-clause spelling.

## Examples

### Example

```ts
If(winding.ne(0), () => {
  Return(f32(1).sub(min_dist))
})
Return(f32(1).add(min_dist))
```

## See also

- [`ReturnIf`](https://typeshade.dev/api/returnif/)

## Source

[`src/core/ir/builder.ts`, line 1427](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/builder.ts#L1427), at commit af54ddad5
