Skip to content

Supported Features

Core Language

FeatureStatus
let, const, varSupported
if/else if/else, for, for...of, while, do...while, switchSupported
break, continue, returnSupported
try/catch/finally, throwSupported
Template literals (`hello ${name}`)Supported
Destructuring (arrays and objects)Supported
Spread operator (...)Supported
Ternary (? :), nullish coalescing (??)Supported
Type assertions (as Type)Supported
typeofSupported (resolved at compile time)
All arithmetic, comparison, logical, bitwise operatorsSupported
Pre/post increment/decrement (++, --)Supported
Compound assignment (+=, -=, *=, /=, |=, &=)Supported
Regular expressions (/pattern/flags)Supported
for...inSupported (desugared to for...of Object.keys())
Computed property access (obj[key])Supported (read and write, for objects with known fields)
Generator functions (function*, yield)Not supported
DecoratorsNot supported
Tagged template literalsNot supported
Labeled statementsNot supported
with statementNot supported
Comma operatorNot supported

Functions

FeatureStatus
Named functionsSupported
Arrow functionsSupported
async/awaitSupported
Default parametersSupported
Rest parameters (...args)Supported
ClosuresSupported (capture by value; post-capture mutation is a compile error)
declare function (FFI)Supported (see FFI)
Async generators / for await...ofNot supported

Types and Data Structures

FeatureStatus
number, string, boolean, null, undefinedSupported
number[], string[] (typed arrays)Supported
Uint8ArraySupported
Object literals / interfaces (fixed-layout structs)Supported
Map<K, V>, Set<T>Supported
Enums (numeric and string)Supported
Type aliasesSupported
Union types (string | null)Supported (nullable unions only)
any, unknown, neverNot supported
User-defined generics (<T>)Not supported
Intersection types (A & B)Not supported
Mapped / conditional / template literal typesNot supported
satisfies, instanceof, SymbolNot supported
WeakMap, WeakSet, WeakRefNot supported
SharedArrayBuffer, AtomicsNot supported
FinalizationRegistry, IntlNot supported

Classes & Interfaces

FeatureStatus
Properties (typed fields)Supported
ConstructorsSupported
Parameter properties (constructor(private name: string))Supported
Instance methodsSupported
Getters / settersSupported
extends (single inheritance)Supported
implementsSupported
Interface inheritance (extends)Supported
Static methods and fieldsSupported
Abstract classesNot supported
Private class fields (#field)Not supported
DecoratorsNot supported

Notes:

  • Static dispatch — method calls are resolved at compile time based on the declared type, not the runtime type
  • Interfaces are data-only — interfaces define fields, not methods. To attach methods to a type, use a class
  • Access modifiersprivate/protected/readonly are parsed but not enforced at runtime. Run chad init for editor-level type checking
  • Interface field ordering — object literals are automatically reordered to match the interface's declared field order

Modules

FeatureStatus
import { foo } from './bar'Supported
import * as bar from './bar'Supported
import { foo as baz } from './bar'Supported
Default importsSupported
Named exportsSupported
Re-exports (export { foo } from './bar')Supported
export defaultSupported
Dynamic import()Not supported

Async

FeatureStatus
async/awaitSupported
Promise.all, Promise.race, Promise.allSettled, Promise.anySupported
Promise.resolve, Promise.rejectSupported
.then(), .catch(), .finally()Supported
setTimeout, setInterval, clearTimeout, clearIntervalSupported

JSX

FeatureStatus
JSX elements (<Tag prop={v} />)Supported (desugared to createElement() calls)
Fragments (<>...</>)Supported
Expression attributes (prop={expr})Supported
String attributes (prop="text")Supported
Self-closing elements (<Tag />)Supported
Nested elementsSupported

JSX is desugared at parse time into createElement(tag, props, children) calls. You provide the createElement function — ChadScript doesn't ship a framework. Files must use .tsx extension.

tsx
interface Props {
  text: string;
  color: number;
}

function createElement(tag: string, props: Props, children: string[]): string {
  // your rendering logic here
  return tag;
}

const ui = <Label text="hello" color={0xff0000} />;
// desugars to: createElement("Label", { text: "hello", color: 0xff0000 }, [])

Foreign Function Interface (FFI)

declare function lets you call external C functions with zero-cost type mappings:

ts
declare function zr_init(): i8_ptr;
declare function zr_draw_text(engine: i8_ptr, x: i32, y: i32, text: i8_ptr, fg: u32, bg: u32): void;

FFI type aliases map directly to LLVM types with no double conversion:

Type AliasLLVM TypeDescription
i8, i16, i32, i64i8, i16, i32, i64Signed integers
u8, u16, u32, u64i8, i16, i32, i64Unsigned integers (same LLVM type)
f32float32-bit float
f64double64-bit float
i8_ptr, ptri8*Opaque pointer

Link external object files with --link-obj:

bash
chad build app.ts -o app --link-obj bridge.o --link-obj /path/to/libfoo.a

Linker flags (-lm, -lpthread, etc.) are auto-detected from linked libraries.

Dynamic Features

These require runtime code evaluation and are not possible in a native compiler:

FeatureStatus
eval()Not supported
Function() constructorNot supported
Proxy / ReflectNot supported
globalThisNot supported

Numbers

All numbers are number (no separate integer type). Integer literal expressions use native 64-bit integer instructions — 42 + 10 compiles to add i64 rather than fadd double. Division always returns a float. Variables are stored as doubles.

Strings

Strings are null-terminated C strings, not JavaScript's UTF-16 strings. They work fine for ASCII and UTF-8 text but cannot contain embedded null bytes.

Closures

Arrow functions and nested functions can capture outer variables, but captures are by value, not by reference. Mutating a variable after a closure captures it is a compile error:

typescript
let x = 1;
const f = () => console.log(x);
x = 2; // error: variable 'x' is reassigned after being captured by a closure

This is enforced at compile time because the closure would silently see the old value — a common source of bugs in native code where there's no runtime to help.

Inline lambdas with captures work in array methods:

typescript
const offset = 10;
const result = [1, 2, 3].map(x => x + offset); // [11, 12, 13]

npm Compatibility

npm packages work if they only use supported TypeScript features. In practice most packages use generics, dynamic types, or runtime features that ChadScript doesn't support, so compatibility is limited.

Standard Library

Everything is built in — no npm install needed. See the Standard Library for the full API reference.