TypeScript constructs
TypeShade is TypeScript's syntax, checked by a shader compiler. A construct either lowers to shader code or is refused with a reason, and the emitted pane of every card is what the compiler wrote at the pinned commit. There are 69 of them, on the section pages below.
How to read a card
The head of a card names the construct, and a badge marks one the language refuses. The sentence under it says what becomes of the construct. The left pane is the TypeScript, taken from a "use typeshade" program that is compiled while this page is built. The right pane is the emitted WGSL, cut out of that program by name, and a refused card carries the compiler's own code and message there instead.
A card says what happens. The pages before this one say why: types, functions, control flow, GPU types and resources. The builtins have a table of their own.
Sections
- Declarations 11 constructs
- What a constant, a variable, an enum, a type alias, an interface and a namespace become in a "use typeshade" file, and what is emitted for each.
- Functions 11 constructs
- Helpers, arrow functions, overloads, recursion, entry points and the calls the compiler refuses, each with the shader text written for it.
- Classes 14 constructs
- Constructors, methods, static members, inheritance, mixins and generics, each with the struct and the functions the compiler writes for it.
- Control flow 10 constructs
- Conditions, counted loops, while, switch, the ternary, break, continue and discard, with the shader text written for each and the loops refused.
- Expressions and types 16 constructs
- Assertions, destructuring, spreads, literals and the values a shader cannot build while it runs, each with the shader text or the refusal it gets.
- Emulated double 7 constructs
- Neither target has a 64-bit float, so a double is a pair of single words. What the compiler rewrites, and the calls it puts in place of the arithmetic.
Every program on this page is compiled at the pinned commit while the site is built, and a snippet that stops compiling stops the build. The grammar itself is the surface document.