Skip to content

Classes & Interfaces

Classes and interfaces work like standard TypeScript with a few differences.

Key differences from TypeScript:

  • No instanceof — there are no runtime type tags
  • Static dispatch — method calls are resolved at compile time, not dynamically
  • Interfaces are data-only — interfaces define fields, not methods. To attach methods to a type, use a class.
  • Access modifiers not enforced at runtimeprivate/protected are parsed but all fields are accessible in the compiled output. Run chad init to get TypeScript type-checking in your editor, which will flag access violations before you compile.

What's Supported

FeatureStatus
Properties (typed fields)Supported
ConstructorsSupported
Parameter propertiesSupported
Instance methodsSupported
Getters / settersSupported
extends (single inheritance)Supported
implementsSupported
Interface inheritance (extends)Supported
Static methods and fieldsSupported
Abstract classesNot yet supported
DecoratorsNot supported

Interface Field Ordering

One ChadScript-specific detail: object literals are automatically reordered to match the interface's declared field order. You can write fields in any order:

typescript
interface Person {
  name: string;
  age: number;
  city: string;
}

const p: Person = { age: 30, city: "NYC", name: "Alice" }; // works fine