Skip to main content

TypeData

Enum TypeData 

Source
pub enum TypeData {
Show 30 variants Intrinsic(IntrinsicKind), Literal(LiteralValue), Object(ObjectShapeId), ObjectWithIndex(ObjectShapeId), Union(TypeListId), Intersection(TypeListId), Array(TypeId), Tuple(TupleListId), Function(FunctionShapeId), Callable(CallableShapeId), TypeParameter(TypeParamInfo), BoundParameter(u32), Lazy(DefId), Recursive(u32), Enum(DefId, TypeId), Application(TypeApplicationId), Conditional(ConditionalTypeId), Mapped(MappedTypeId), IndexAccess(TypeId, TypeId), TemplateLiteral(TemplateLiteralId), TypeQuery(SymbolRef), KeyOf(TypeId), ReadonlyType(TypeId), UniqueSymbol(SymbolRef), Infer(TypeParamInfo), ThisType, StringIntrinsic { kind: StringIntrinsicKind, type_arg: TypeId, }, ModuleNamespace(SymbolRef), NoInfer(TypeId), Error,
}
Expand description

The structural “shape” of a type. This is the key used for interning - structurally identical types will have the same TypeData and therefore the same TypeId.

Variants§

§

Intrinsic(IntrinsicKind)

Intrinsic types (any, unknown, never, void, null, undefined, boolean, number, string, bigint, symbol, object)

§

Literal(LiteralValue)

Literal types (“hello”, 42, true, 123n)

§

Object(ObjectShapeId)

Object type with sorted property list for structural identity

§

ObjectWithIndex(ObjectShapeId)

Object type with index signatures For objects like { [key: string]: number, foo: string }

§

Union(TypeListId)

Union type (A | B | C)

§

Intersection(TypeListId)

Intersection type (A & B & C)

§

Array(TypeId)

Array type

§

Tuple(TupleListId)

Tuple type

§

Function(FunctionShapeId)

Function type

§

Callable(CallableShapeId)

Callable type with overloaded signatures For interfaces with call/construct signatures

§

TypeParameter(TypeParamInfo)

Type parameter (generic)

§

BoundParameter(u32)

Bound type parameter using De Bruijn index for alpha-equivalence.

Represents a type parameter relative to the current binding scope. Used by the Canonicalizer to achieve alpha-equivalence, where type F<T> = T and type G<U> = U are considered identical.

§Alpha-Equivalence (Task #32)

When canonicalizing generic types, we replace named type parameters with positional indices to achieve structural identity.

§Example
type F<T> = { value: T };  // canonicalizes to Object({ value: BoundParameter(0) })
type G<U> = { value: U };  // also canonicalizes to Object({ value: BoundParameter(0) })
// Both get the same TypeId because they're structurally identical
§De Bruijn Index Semantics
  • BoundParameter(0) = the most recently bound type parameter
  • BoundParameter(1) = the second-most recently bound type parameter
  • BoundParameter(n) = the (n+1)th-most recently bound type parameter
§

Lazy(DefId)

Reference to a named type (interface, class, type alias) Uses SymbolId to break infinite recursion DEPRECATED: Use Lazy(DefId) for new code. This is kept for backward compatibility during the migration from SymbolRef to DefId. PHASE 4.2: REMOVED - Migration complete, all types now use Lazy(DefId) Lazy reference to a type definition.

Unlike Ref(SymbolRef) which references Binder symbols, Lazy(DefId) uses Solver-owned identifiers that:

  • Don’t require Binder context
  • Support content-addressed hashing for LSP stability
  • Enable Salsa integration for incremental compilation

The type is evaluated lazily when first accessed, resolving to the actual type stored in the DefinitionStore.

§Migration

Eventually all Ref(SymbolRef) usages will be replaced with Lazy(DefId).

§

Recursive(u32)

Recursive type reference using De Bruijn index.

Represents a back-reference to a type N levels up the nesting path. This is used for canonicalizing recursive types to achieve O(1) equality.

§Graph Isomorphism (Task #32)

When canonicalizing recursive type aliases, we replace cycles with relative De Bruijn indices instead of absolute Lazy references.

§Example
type A = { x: A };  // canonicalizes to Object({ x: Recursive(0) })
type B = { x: B };  // also canonicalizes to Object({ x: Recursive(0) })
// Both get the same TypeId because they're structurally identical
§De Bruijn Index Semantics
  • Recursive(0) = the current type itself (immediate recursion)
  • Recursive(1) = one level up (parent in the nesting chain)
  • Recursive(n) = n levels up
§Nominal vs Structural

This is ONLY used for structural types (type aliases). Nominal types (classes, interfaces) preserve their Lazy(DefId) for nominal identity.

§

Enum(DefId, TypeId)

Enum type with nominal identity and structural member types.

Enums are nominal types - two different enums with the same member types are NOT compatible (e.g., enum E1 { A, B } is not assignable to enum E2 { A, B }).

  • DefId: The unique identity of the enum (for E1 vs E2 nominal checking)
  • TypeId: The structural union of member types (e.g., 0 | 1 for numeric enums), used for assignability to primitives (e.g., E1 assignable to number)
§

Application(TypeApplicationId)

Generic type application (Base)

§

Conditional(ConditionalTypeId)

Conditional type (T extends U ? X : Y)

§

Mapped(MappedTypeId)

Mapped type ({ [K in Keys]: ValueType })

§

IndexAccess(TypeId, TypeId)

Index access type (T[K])

§

TemplateLiteral(TemplateLiteralId)

Template literal type (hello${string}world)

§

TypeQuery(SymbolRef)

Type query (typeof expression in type position)

§

KeyOf(TypeId)

KeyOf type operator (keyof T)

§

ReadonlyType(TypeId)

Readonly type modifier (readonly T[])

§

UniqueSymbol(SymbolRef)

Unique symbol type

§

Infer(TypeParamInfo)

Infer type (infer R in conditional types)

§

ThisType

This type (polymorphic this)

§

StringIntrinsic

String manipulation intrinsic types Uppercase, Lowercase, Capitalize, Uncapitalize

Fields

§type_arg: TypeId
§

ModuleNamespace(SymbolRef)

Module namespace type (import * as ns from “module”) Uses SymbolRef for lazy evaluation to avoid circular dependency issues

§

NoInfer(TypeId)

NoInfer utility type (TypeScript 5.4+) Prevents inference from flowing through this type position. During inference, this blocks inference. During evaluation/subtyping, it evaluates to the inner type (transparent).

§

Error

Error type for recovery

Trait Implementations§

Source§

impl Clone for TypeData

Source§

fn clone(&self) -> TypeData

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TypeData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for TypeData

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TypeData

Source§

fn eq(&self, other: &TypeData) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for TypeData

Source§

impl StructuralPartialEq for TypeData

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more