---
title: "stageOf(): function in IR, TypeShade API reference"
description: "stageOf, a function in IR. The stage of a function declaration: 'vertex', 'fragment' or 'compute' for an entry point, undefined for a helper."
url: https://typeshade.dev/api/stageof/
language: en
---

# `stageOf()`

Function in IR

The stage of a function declaration: 'vertex', 'fragment' or 'compute' for an entry point, undefined for a helper.

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

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

## Syntax

```ts
const stageOf: (
  f: Pick<FuncDecl, "stage" | "attrs">,
) => "vertex" | "fragment" | "compute" | undefined
```

## Parameters

**`f` `Pick<FuncDecl, 'stage' | 'attrs'>`**

## Return value

`'vertex' | 'fragment' | 'compute' | undefined`

## Description

The stage of a function declaration: `'vertex'`, `'fragment'` or `'compute'` for an entry point, `undefined` for a helper. It reads the structured `stage` field first and falls back to the `attrs` strings for a hand-built `FuncDecl` literal. Every stage decision in the package ([`reflect`](https://typeshade.dev/api/reflect/), the capability gate, GLSL entry classification, the roots of dead-function elimination) goes through this one function.

## See also

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

## Source

[`src/core/ir/nodes.ts`, line 599](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/nodes.ts#L599), at commit af54ddad5
