pub enum TypeKind {
Interface {
generics: Vec<String>,
methods: BTreeMap<String, MethodSig>,
properties: BTreeMap<String, PropertySig>,
index: Option<IndexSignature>,
dispatch: Dispatch,
doc: Option<DocComment>,
},
NumberEnum {
variants: Vec<(String, f64)>,
doc: Option<DocComment>,
},
StringEnum {
variants: Vec<(String, String)>,
doc: Option<DocComment>,
},
Alias {
generics: Vec<String>,
ty: Type,
doc: Option<DocComment>,
},
Class {Show 14 fields
generics: Vec<String>,
fields: BTreeMap<String, FieldSig>,
narrowing_checks: BTreeMap<String, FieldNarrowingCheck>,
methods: BTreeMap<String, MethodSig>,
method_visibility: BTreeMap<String, Visibility>,
accessors: Vec<AccessorSig>,
constructor: Vec<Param>,
constructor_visibility: Visibility,
statics: BTreeMap<String, MethodSig>,
static_visibility: BTreeMap<String, Visibility>,
static_fields: BTreeMap<String, FieldSig>,
extends: Option<ClassExtends>,
implements: Vec<MangledName>,
doc: Option<DocComment>,
},
}Variants§
Interface
Single declaration site per name — no reopening, no extends in v1.
Codegen has no Wasm representation for the interface itself; it only drives method dispatch.
Fields
properties: BTreeMap<String, PropertySig>Read via expr.name (not expr.name()). Writable unless the
declaration carries a readonly modifier (PropertySig.readonly).
index: Option<IndexSignature>doc: Option<DocComment>NumberEnum
Auto-numbered at bind time (source AST stores None; bound form holds the resolved value).
StringEnum
Every variant must have an explicit initializer; auto-numbering doesn’t apply.
Alias
Stored ty is the fully resolved alias body. At use sites the inferer wraps the result in
Type::Alias { name, args, ty } so the alias label flows through Display.
Class
A class declaration. Nominal (Type::ClassRef keys on the symbol’s mangled name).
Single inheritance via extends; implements is structural conformance only.
Privacy is enforced at the access site (module-scoped), not by stripping here.
Methods are always vtable-dispatched (overrides slot into the inherited index),
so there is no per-class dispatch — unlike Interface, where the prelude opts
into direct/static dispatch.
Fields
generics: Vec<String>Class-level type parameters, erased at codegen (every T-typed slot
is a boxed value slot). Substituted at use sites from the
ClassRef’s args.
narrowing_checks: BTreeMap<String, FieldNarrowingCheck>Runtime read guards for fields whose declaration narrows an inherited slot. Carried across packages because the consumer reconstructs the class layout and emits its reads independently.
method_visibility: BTreeMap<String, Visibility>Per-method visibility, keyed alongside methods (kept separate so
MethodSig stays shared with interfaces, which have no visibility).
accessors: Vec<AccessorSig>Accessor functions (get/set) — one entry each, mirroring the typed
AST. A property’s read type (getter) and write type (setter) are
independent; the property itself is also in fields (its read type) for
the type system. Carries the setter’s parameter name + type so the
public surface (docs, .d.ts) renders the full signature.
constructor_visibility: VisibilityA private constructor may be called, and the class extended, only in
the module that declares the class.
statics: BTreeMap<String, MethodSig>Static methods — self-less functions dispatched by name on the class
object (Class#static#name), never through the vtable. Inherited down
the extends chain by name resolution at the use site.
static_visibility: BTreeMap<String, Visibility>Per-static-method visibility, mirroring method_visibility.
static_fields: BTreeMap<String, FieldSig>Static fields, backed by module globals (Class#static#name). readonly
is declaration-driven; a mutable one is writable through the class name.
extends: Option<ClassExtends>Resolved parent class, if any.
implements: Vec<MangledName>Resolved interfaces this class declares it implements.
doc: Option<DocComment>