Node
Class in IR
The write-capable node.
import { Node } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
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 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>): voidthis = value;, the one mutation method (the same shape as three.js TSL’s.assign()). JS cannot overload=:x = vwould rebind the JS variable and emit nothing, so mutation is a method. For a compound update writex.assign(x.add(v));addis the pure expression. The value lifts to this node’s scalar kind.addAssign(value: ArithArg<K>): voidthis += value;— the compound assignment, emitted asx += von both targets. The same statement the"use typeshade"surface’sx += vlowers to, so a helper ported between the two authoring surfaces keeps its emit.this.assign(this.add(value))is the other spelling and emitsx = (x + v). Both are correct; this one is shorter and is the one the seam is defined on.subAssign(value: ArithArg<K>): voidthis -= value;, the subtractingNode.addAssign.mulAssign(value: ArithArg<K>): voidthis *= value;, the multiplyingNode.addAssign.divAssign(value: ArithArg<K>): voidthis /= value;, the dividingNode.addAssign.
In the guide
See also
Source
src/core/ir/node.ts, line 822, at commit 26de7be8