---
title: "ExternVarDecl: interface in IR, TypeShade API reference"
description: "ExternVarDecl, an interface in IR. A host-provided global, the declaration behind externVar."
url: https://typeshade.dev/api/externvardecl/
language: en
---

# `ExternVarDecl`

Interface in IR

A host-provided global, the declaration behind externVar.

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

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

## Syntax

```ts
interface ExternVarDecl {
  readonly name: string;
  readonly type: ShaderType;
  readonly spelling?: { readonly wgsl?: string; readonly glsl?: string };
  readonly stage?: 'vertex' | 'fragment' | 'compute';
}
```

## Description

A host-provided global, the declaration behind [`externVar`](https://typeshade.dev/api/externvar/). It is the variable counterpart of [`externFn`](https://typeshade.dev/api/externfn/).

It emits nothing on either backend: the host’s prelude declares the symbol. The declaration exists so that reads of it type-check, survive renaming, and appear in `reflect().requires`, where a host can check them against what its prelude provides.

`spelling` maps the logical name onto what each target writes, so moving to a host that exposes the same value differently (a WGSL struct member or a bound uniform in place of a GLSL prelude global) is a change to the spelling map and leaves the shader source alone.

## Instance properties

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

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

**`spelling` optional read only `{ readonly wgsl?: string; readonly glsl?: string }`**

Per-target spelling. A missing side falls back to `name`.

**`stage` optional read only `'vertex' | 'fragment' | 'compute'`**

Restrict the symbol to one stage, for a host global only that stage’s prelude provides. Advisory metadata for `reflect().requires`; nothing gates on it.

## See also

- [`externVar`](https://typeshade.dev/api/externvar/)
- [`externFn`](https://typeshade.dev/api/externfn/)

## Source

[`src/core/ir/nodes/host-interface-decls.ts`, line 89](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/nodes/host-interface-decls.ts#L89), at commit af54ddad5
