---
title: "emitConst(): function in Emit, TypeShade API reference"
description: "emitConst, a function in Emit. Emit one ConstDecl as a WGSL const line, without the surrounding module."
url: https://typeshade.dev/api/emitconst/
language: en
---

# `emitConst()`

Function in Emit

Emit one ConstDecl as a WGSL const line, without the surrounding module.

`import { emitConst } from 'typeshade'`

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

## Syntax

```ts
const emitConst: (c: ConstDecl) => string
```

## Parameters

**`c` `ConstDecl`**

## Return value

`string`

## Description

Use it to compose a shader out of separately authored pieces: emit the constants once, keep the string, and concatenate it with the rest of the source. The line is identical to the one [`emitModule`](https://typeshade.dev/api/emitmodule/) writes for the same declaration, so a piece emitted here and a module emitted there agree, which is what makes concatenation safe.

The declaration is written as given: the passes [`emitModule`](https://typeshade.dev/api/emitmodule/) runs before writing a module do not run here, so pass a declaration that needs none of them. The caveat on [`emitFuncs`](https://typeshade.dev/api/emitfuncs/) applies equally.

## Targets

| Target | Support | Notes |
| --- | --- | --- |
| WGSL (WebGPU) | Supported | Writes WGSL for WebGPU. |
| GLSL ES 3.00 (WebGL2) | Does not apply | |
| CPU oracle | Does not apply | |

## See also

- [`ConstDecl`](https://typeshade.dev/api/constdecl-interface/)
- [`emitModule`](https://typeshade.dev/api/emitmodule/)
- [`emitFuncs`](https://typeshade.dev/api/emitfuncs/)

## Source

[`src/core/backends/wgsl.ts`, line 167](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/backends/wgsl.ts#L167), at commit af54ddad5
