pub trait TypeDatabase {
Show 59 methods
// Required methods
fn intern(&self, key: TypeData) -> TypeId;
fn lookup(&self, id: TypeId) -> Option<TypeData>;
fn intern_string(&self, s: &str) -> Atom;
fn resolve_atom(&self, atom: Atom) -> String;
fn resolve_atom_ref(&self, atom: Atom) -> Arc<str>;
fn type_list(&self, id: TypeListId) -> Arc<[TypeId]>;
fn tuple_list(&self, id: TupleListId) -> Arc<[TupleElement]>;
fn template_list(&self, id: TemplateLiteralId) -> Arc<[TemplateSpan]>;
fn object_shape(&self, id: ObjectShapeId) -> Arc<ObjectShape>;
fn object_property_index(
&self,
shape_id: ObjectShapeId,
name: Atom,
) -> PropertyLookup;
fn function_shape(&self, id: FunctionShapeId) -> Arc<FunctionShape>;
fn callable_shape(&self, id: CallableShapeId) -> Arc<CallableShape>;
fn conditional_type(&self, id: ConditionalTypeId) -> Arc<ConditionalType>;
fn mapped_type(&self, id: MappedTypeId) -> Arc<MappedType>;
fn type_application(&self, id: TypeApplicationId) -> Arc<TypeApplication>;
fn literal_string(&self, value: &str) -> TypeId;
fn literal_number(&self, value: f64) -> TypeId;
fn literal_boolean(&self, value: bool) -> TypeId;
fn literal_bigint(&self, value: &str) -> TypeId;
fn literal_bigint_with_sign(&self, negative: bool, digits: &str) -> TypeId;
fn union(&self, members: Vec<TypeId>) -> TypeId;
fn union_from_sorted_vec(&self, flat: Vec<TypeId>) -> TypeId;
fn union2(&self, left: TypeId, right: TypeId) -> TypeId;
fn union3(&self, first: TypeId, second: TypeId, third: TypeId) -> TypeId;
fn intersection(&self, members: Vec<TypeId>) -> TypeId;
fn intersection2(&self, left: TypeId, right: TypeId) -> TypeId;
fn intersect_types_raw2(&self, left: TypeId, right: TypeId) -> TypeId;
fn array(&self, element: TypeId) -> TypeId;
fn tuple(&self, elements: Vec<TupleElement>) -> TypeId;
fn object(&self, properties: Vec<PropertyInfo>) -> TypeId;
fn object_with_flags(
&self,
properties: Vec<PropertyInfo>,
flags: ObjectFlags,
) -> TypeId;
fn object_with_flags_and_symbol(
&self,
properties: Vec<PropertyInfo>,
flags: ObjectFlags,
symbol: Option<SymbolId>,
) -> TypeId;
fn object_with_index(&self, shape: ObjectShape) -> TypeId;
fn function(&self, shape: FunctionShape) -> TypeId;
fn callable(&self, shape: CallableShape) -> TypeId;
fn template_literal(&self, spans: Vec<TemplateSpan>) -> TypeId;
fn conditional(&self, conditional: ConditionalType) -> TypeId;
fn mapped(&self, mapped: MappedType) -> TypeId;
fn reference(&self, symbol: SymbolRef) -> TypeId;
fn lazy(&self, def_id: DefId) -> TypeId;
fn bound_parameter(&self, index: u32) -> TypeId;
fn recursive(&self, depth: u32) -> TypeId;
fn type_param(&self, info: TypeParamInfo) -> TypeId;
fn type_query(&self, symbol: SymbolRef) -> TypeId;
fn enum_type(&self, def_id: DefId, structural_type: TypeId) -> TypeId;
fn application(&self, base: TypeId, args: Vec<TypeId>) -> TypeId;
fn literal_string_atom(&self, atom: Atom) -> TypeId;
fn union_preserve_members(&self, members: Vec<TypeId>) -> TypeId;
fn readonly_type(&self, inner: TypeId) -> TypeId;
fn keyof(&self, inner: TypeId) -> TypeId;
fn index_access(&self, object_type: TypeId, index_type: TypeId) -> TypeId;
fn this_type(&self) -> TypeId;
fn no_infer(&self, inner: TypeId) -> TypeId;
fn unique_symbol(&self, symbol: SymbolRef) -> TypeId;
fn infer(&self, info: TypeParamInfo) -> TypeId;
fn string_intrinsic(
&self,
kind: StringIntrinsicKind,
type_arg: TypeId,
) -> TypeId;
fn get_class_base_type(&self, symbol_id: SymbolId) -> Option<TypeId>;
fn is_identity_comparable_type(&self, type_id: TypeId) -> bool;
// Provided method
fn object_fresh(&self, properties: Vec<PropertyInfo>) -> TypeId { ... }
}Expand description
Query interface for the solver.
This keeps solver components generic and prevents them from reaching into concrete storage structures directly.
Required Methods§
fn intern(&self, key: TypeData) -> TypeId
fn lookup(&self, id: TypeId) -> Option<TypeData>
fn intern_string(&self, s: &str) -> Atom
fn resolve_atom(&self, atom: Atom) -> String
fn resolve_atom_ref(&self, atom: Atom) -> Arc<str>
fn type_list(&self, id: TypeListId) -> Arc<[TypeId]>
fn tuple_list(&self, id: TupleListId) -> Arc<[TupleElement]>
fn template_list(&self, id: TemplateLiteralId) -> Arc<[TemplateSpan]>
fn object_shape(&self, id: ObjectShapeId) -> Arc<ObjectShape>
fn object_property_index( &self, shape_id: ObjectShapeId, name: Atom, ) -> PropertyLookup
fn function_shape(&self, id: FunctionShapeId) -> Arc<FunctionShape>
fn callable_shape(&self, id: CallableShapeId) -> Arc<CallableShape>
fn conditional_type(&self, id: ConditionalTypeId) -> Arc<ConditionalType>
fn mapped_type(&self, id: MappedTypeId) -> Arc<MappedType>
fn type_application(&self, id: TypeApplicationId) -> Arc<TypeApplication>
fn literal_string(&self, value: &str) -> TypeId
fn literal_number(&self, value: f64) -> TypeId
fn literal_boolean(&self, value: bool) -> TypeId
fn literal_bigint(&self, value: &str) -> TypeId
fn literal_bigint_with_sign(&self, negative: bool, digits: &str) -> TypeId
fn union(&self, members: Vec<TypeId>) -> TypeId
fn union_from_sorted_vec(&self, flat: Vec<TypeId>) -> TypeId
fn union2(&self, left: TypeId, right: TypeId) -> TypeId
fn union3(&self, first: TypeId, second: TypeId, third: TypeId) -> TypeId
fn intersection(&self, members: Vec<TypeId>) -> TypeId
fn intersection2(&self, left: TypeId, right: TypeId) -> TypeId
Sourcefn intersect_types_raw2(&self, left: TypeId, right: TypeId) -> TypeId
fn intersect_types_raw2(&self, left: TypeId, right: TypeId) -> TypeId
Raw intersection without normalization (used to avoid infinite recursion)
fn array(&self, element: TypeId) -> TypeId
fn tuple(&self, elements: Vec<TupleElement>) -> TypeId
fn object(&self, properties: Vec<PropertyInfo>) -> TypeId
fn object_with_flags( &self, properties: Vec<PropertyInfo>, flags: ObjectFlags, ) -> TypeId
fn object_with_flags_and_symbol( &self, properties: Vec<PropertyInfo>, flags: ObjectFlags, symbol: Option<SymbolId>, ) -> TypeId
fn object_with_index(&self, shape: ObjectShape) -> TypeId
fn function(&self, shape: FunctionShape) -> TypeId
fn callable(&self, shape: CallableShape) -> TypeId
fn template_literal(&self, spans: Vec<TemplateSpan>) -> TypeId
fn conditional(&self, conditional: ConditionalType) -> TypeId
fn mapped(&self, mapped: MappedType) -> TypeId
fn reference(&self, symbol: SymbolRef) -> TypeId
fn lazy(&self, def_id: DefId) -> TypeId
fn bound_parameter(&self, index: u32) -> TypeId
fn recursive(&self, depth: u32) -> TypeId
fn type_param(&self, info: TypeParamInfo) -> TypeId
fn type_query(&self, symbol: SymbolRef) -> TypeId
fn enum_type(&self, def_id: DefId, structural_type: TypeId) -> TypeId
fn application(&self, base: TypeId, args: Vec<TypeId>) -> TypeId
fn literal_string_atom(&self, atom: Atom) -> TypeId
fn union_preserve_members(&self, members: Vec<TypeId>) -> TypeId
fn readonly_type(&self, inner: TypeId) -> TypeId
fn keyof(&self, inner: TypeId) -> TypeId
fn index_access(&self, object_type: TypeId, index_type: TypeId) -> TypeId
fn this_type(&self) -> TypeId
fn no_infer(&self, inner: TypeId) -> TypeId
fn unique_symbol(&self, symbol: SymbolRef) -> TypeId
fn infer(&self, info: TypeParamInfo) -> TypeId
fn string_intrinsic( &self, kind: StringIntrinsicKind, type_arg: TypeId, ) -> TypeId
Sourcefn get_class_base_type(&self, symbol_id: SymbolId) -> Option<TypeId>
fn get_class_base_type(&self, symbol_id: SymbolId) -> Option<TypeId>
Get the base class type for a symbol (class/interface).
Returns the TypeId of the extends clause, or None if the symbol doesn’t extend anything.
This is used by the BCT algorithm to find common base classes.
Sourcefn is_identity_comparable_type(&self, type_id: TypeId) -> bool
fn is_identity_comparable_type(&self, type_id: TypeId) -> bool
Check if a type can be compared by TypeId identity alone (O(1) equality).
Identity-comparable types include literals, enum members, unique symbols, null, undefined,
void, never, and tuples composed entirely of identity-comparable types.
Results are cached for O(1) lookup after first computation.