Skip to main content

IndexSignatureResolver

Struct IndexSignatureResolver 

Source
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>

Source

pub fn new(db: &'a dyn TypeDatabase) -> Self

Create a new index signature resolver.

Source

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
Source

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.

Source

pub fn is_readonly(&self, obj: TypeId, kind: IndexKind) -> bool

Check if an index signature is readonly.

§Parameters
  • obj: The type to check
  • kind: Which index signature to check (string or number)
§Returns

true if the requested index signature is readonly, false otherwise.

§Examples
  • { readonly [x: string]: string } with IndexKind::Stringtrue
  • { [x: string]: string } with IndexKind::Stringfalse
Source

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.

Source

pub fn has_index_signature(&self, obj: TypeId, kind: IndexKind) -> bool

Check if a type has a specific index signature.

§Parameters
  • obj: The type to check
  • kind: Which index signature to check for (string or number)
§Returns

true if the type has the requested index signature, false otherwise.

Source

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

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> 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, 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