---
title: "Node: class in IR, TypeShade API reference for developers"
description: "Node, a class in IR. The write-capable node. The intermediate representation every backend reads: nodes, statements and declarations."
url: https://typeshade.dev/api/node/
language: en
---

# `Node`

Class in IR

The write-capable node.

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

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

## Syntax

```ts
class Node<K extends string = string> extends ReadonlyNode<K>
```

## Description

Every value-producing method and builtin, and `Var()`, return this subtype, which adds one method, `.assign()`, over the read-only [`ReadonlyNode`](https://typeshade.dev/api/readonlynode/) base. `Let()`, a function parameter and a module constant are the `ReadonlyNode` supertype, so `someLet.assign(…)` is a `tsc` error. The split is type-level only: the runtime is one class, and the emitted WGSL and GLSL do not depend on which type a value carried.

## Instance methods

**`assign` `(value: ArithArg<K>): void`**

`this = value;`, the one mutation method (the same shape as three.js TSL’s `.assign()`). JS cannot overload `=`: `x = v` would rebind the JS variable and emit nothing, so mutation is a method. For a compound update write `x.assign(x.add(v))`; `add` is the pure expression. The value lifts to this node’s scalar kind.

**`addAssign` `(value: ArithArg<K>): void`**

`this += value;` — the compound assignment, emitted as `x += v` on both targets. The same statement the `"use typeshade"` surface’s `x += v` lowers to, so a helper ported between the two authoring surfaces keeps its emit.

`this.assign(this.add(value))` is the other spelling and emits `x = (x + v)`. Both are correct; this one is shorter and is the one the seam is defined on.

**`subAssign` `(value: ArithArg<K>): void`**

`this -= value;`, the subtracting [`Node.addAssign`](https://typeshade.dev/api/node/).

**`mulAssign` `(value: ArithArg<K>): void`**

`this *= value;`, the multiplying [`Node.addAssign`](https://typeshade.dev/api/node/).

**`divAssign` `(value: ArithArg<K>): void`**

`this /= value;`, the dividing [`Node.addAssign`](https://typeshade.dev/api/node/).

## See also

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

## Source

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