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

# `Discard()`

Function in Authoring

Push a discard; onto the innermost scope.

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

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

## Syntax

```ts
const Discard: () => void
```

## Return value

`void`

## Description

Push a `discard;` onto the innermost scope. It ends the current fragment invocation with no color or depth write, the fragment-only terminator of both WGSL and GLSL. It is typically guarded by an `If` for a cull test: a backface, an alpha clip, an out-of-bounds sample.

## Examples

### Example

```ts
If(cosC.lt(0), () => {
  Discard()
})
```

## Source

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