---
title: "constRef(): IR builder function in typeshade/core/ir"
description: "constRef, an IR builder function in typeshade/core/ir. A reference to a module-level constant by name, such as one declared with constExpr."
url: https://typeshade.dev/api/constref/
language: en
---

# `constRef()`

Function in Values

A reference to a module-level constant by name, such as one declared with constExpr.

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

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

## Syntax

```ts
function constRef<T extends ShaderType = typeof f32T>(
  name: string,
  type?: T,
): ReadonlyNode<KeyOf<T>>
```

## Parameters

**`name` `string`**

**`type` optional `T extends ShaderType`**

## Return value

`ReadonlyNode<KeyOf<T>>`

## Description

The type defaults to `f32`.

## Source

[`src/core/ir/node.ts`, line 887](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L887), at commit af54ddad5
