pub struct IndexSignatureResolver<'a> { /* private fields */ }Expand description
Resolver for index signature queries on types.
This struct provides a unified interface for querying index signatures
across different type representations (ObjectWithIndex, Union, etc.).
Implementations§
Source§impl<'a> IndexSignatureResolver<'a>
impl<'a> IndexSignatureResolver<'a>
Sourcepub fn new(db: &'a dyn TypeDatabase) -> Self
pub fn new(db: &'a dyn TypeDatabase) -> Self
Create a new index signature resolver.
Sourcepub fn resolve_string_index(&self, obj: TypeId) -> Option<TypeId>
pub fn resolve_string_index(&self, obj: TypeId) -> Option<TypeId>
Resolve the string index signature type from an object type.
Returns Some(value_type) if the object has a string index signature,
None otherwise.
§Examples
{ [key: string]: number }→Some(TypeId::NUMBER){ [key: string]: string }→Some(TypeId::STRING){ a: number }→None
Sourcepub fn resolve_number_index(&self, obj: TypeId) -> Option<TypeId>
pub fn resolve_number_index(&self, obj: TypeId) -> Option<TypeId>
Resolve the numeric index signature type from an object type.
Returns Some(value_type) if the object has a numeric index signature,
None otherwise.
§Examples
{ [key: number]: string }→Some(TypeId::STRING){ [key: number]: number }→Some(TypeId::NUMBER){ a: number }→None
Note: Array and tuple types have implicit numeric index signatures.
Sourcepub fn is_readonly(&self, obj: TypeId, kind: IndexKind) -> bool
pub fn is_readonly(&self, obj: TypeId, kind: IndexKind) -> bool
Check if an index signature is readonly.
§Parameters
obj: The type to checkkind: Which index signature to check (string or number)
§Returns
true if the requested index signature is readonly, false otherwise.
§Examples
{ readonly [x: string]: string }withIndexKind::String→true{ [x: string]: string }withIndexKind::String→false
Sourcepub fn get_index_info(&self, obj: TypeId) -> IndexInfo
pub fn get_index_info(&self, obj: TypeId) -> IndexInfo
Get all index signatures from a type.
Returns an IndexInfo struct containing both string and numeric
index signatures if present.
Sourcepub fn has_index_signature(&self, obj: TypeId, kind: IndexKind) -> bool
pub fn has_index_signature(&self, obj: TypeId, kind: IndexKind) -> bool
Sourcepub fn is_numeric_index_name(&self, name: &str) -> bool
pub fn is_numeric_index_name(&self, name: &str) -> bool
Check if a property name is a valid numeric index.
§Examples
"0"→true"42"→true"foo"→false"-1"→false"NaN"→true"Infinity"→true