Concepts
Strict TypeScript syntax over WebAssembly semantics — plus closures, iteration, and generators, which upstream AssemblyScript never shipped.
Strictness
There is no any, no undefined, and no union types
except nullable references. Conversions are explicit — x as u8,
f as i32 (float-to-int truncates, traps out of range). Equality is
two operators: == is value equality (strings compare contents),
=== is identity. Truthiness is JS-like: 0,
NaN, null, and "" are falsy.
Template literals
Template strings interpolate, and every piece stringifies through its
type’s toString: primitives via their wrapper classes
(I32, F64, Bool, …, honoring their declared
radix defaults), classes directly or through virtual stubs — subclass overrides
dispatch correctly — and interfaces through dispatch stubs. Pieces chain through
String.__concat, with the accumulator kept in a managed local so
intermediates stay rooted under both GC runtimes.
declare function print(s: string): void;
export function demo(): void {
let name = "rasc";
let runs = 3;
print(`compiled ${name} ${runs} times`); // nested templates work too
}
What cannot appear inside ${} errors explicitly rather than
guessing: nullable values, value classes, function values, v128,
void, and classes with no (or a wrongly-typed)
toString.
Program structure
- Whole-program compilation from the entry file; only what its exports
reach is compiled. Entry-file
exports become wasm exports. - Top-level statements run in the wasm start function. Library global initializers run first, so the allocator is live before user code; in Rive projects, top-level statements of all files run in start — that is what executes imported scripts’ registration.
- Relative imports resolve against the importing file; bare specifiers
against
--lib. Cyclic imports work.
The extensions get their own chapters:
Classes & Generics covers reference
classes, interfaces, and monomorphized generics;
Closures & Iteration the native
closures, for..of, spread arguments, and generators upstream never
shipped; and Decorators the annotation
surface.