---
title: "ModuleVarDecl: interface in IR, TypeShade API reference"
description: "ModuleVarDecl, an interface in IR. One entry of ModuleDecl.vars: a module-scope variable that is not a resource."
url: https://typeshade.dev/api/modulevardecl/
language: en
---

# `ModuleVarDecl`

Interface in IR

One entry of ModuleDecl.vars: a module-scope variable that is not a resource.

`import type { ModuleVarDecl } from 'typeshade'`
`import type { ModuleVarDecl } from 'typeshade/core/ir'`

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

## Syntax

```ts
interface ModuleVarDecl {
  readonly name: string;
  readonly space: 'workgroup' | 'private';
  readonly type: ShaderType;
  readonly init?: Expr;
}
```

## Description

`workgroup` is WGSL’s `var<workgroup>`, memory one workgroup’s invocations share, zero at the start of each workgroup and never initialised. `private` is WGSL’s `var<private>`, a value each invocation owns for its lifetime, `init` or zero at its start. Neither has a group, a binding or a byte layout, so [`reflect`](https://typeshade.dev/api/reflect/) reports nothing for one; a host never binds it.

## Instance properties

**`name` read only `string`**

**`space` read only `'workgroup' | 'private'`**

**`type` read only `ShaderType`**

**`init` optional read only `Expr`**

The initial value, a constant expression over literals and module consts. Only a `private` variable carries one; WGSL forbids an initializer on `workgroup` memory.

## See also

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

## Source

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