pub trait ImportResolution {
// Required methods
fn imported_value_type(
&self,
from: &FilePath,
module: &str,
name: &ImportedName,
depth: u32,
) -> Option<Type>;
fn imported_alias_type(
&self,
from: &FilePath,
module: &str,
name: &ImportedName,
depth: u32,
) -> Followed;
fn imported_return_type(
&self,
from: &FilePath,
module: &str,
name: &ImportedName,
depth: u32,
) -> Option<Type>;
fn imported_export(
&self,
from: &FilePath,
module: &str,
name: &ImportedName,
) -> Option<ExportTarget>;
}Expand description
What an oracle asks its host when a name comes from another file.
A trait rather than a concrete provider, so this crate’s layering holds: the oracle reads
one tree and nothing else, and every question about which other file and how deep
belongs to the value that owns the declaration cache and the budget. An oracle with no
implementation attached answers exactly what it answered before cross-file resolution
existed, which is what keeps TypeScriptOracle::new a within-file oracle.
Every method takes the importing file, because a relative specifier means nothing
without one, and a depth already spent, because a bound reset at every file boundary is
not a bound.
Required Methods§
Sourcefn imported_value_type(
&self,
from: &FilePath,
module: &str,
name: &ImportedName,
depth: u32,
) -> Option<Type>
fn imported_value_type( &self, from: &FilePath, module: &str, name: &ImportedName, depth: u32, ) -> Option<Type>
The type an imported value has, computed in its declaring file’s own context.
Sourcefn imported_alias_type(
&self,
from: &FilePath,
module: &str,
name: &ImportedName,
depth: u32,
) -> Followed
fn imported_alias_type( &self, from: &FilePath, module: &str, name: &ImportedName, depth: u32, ) -> Followed
The type an imported type alias names, when the imported name is one.
Deliberately not “the type of the imported type”. An imported class or interface keeps
its own nominal identity and its use-site symbol — replacing it with whatever its
declaration file says would drop the module the name was imported from, which is the
one field lanekeep/no-restricted-types matches on. Only an alias is transparent,
exactly as a same-file type Amount = number already is.
Returns Followed rather than Option<Type> because the caller’s fallback depends
on why there is no type: a name that simply is not an alias keeps its own nominal
identity (as it always has), but a name that is an alias whose chain was cut by
MAX_DEPTH must not — falling back there would answer with an intermediate file’s
own nominal type, a confident guess rather than the honest “unknown” a cut chain
deserves. See Followed’s own documentation.
Sourcefn imported_return_type(
&self,
from: &FilePath,
module: &str,
name: &ImportedName,
depth: u32,
) -> Option<Type>
fn imported_return_type( &self, from: &FilePath, module: &str, name: &ImportedName, depth: u32, ) -> Option<Type>
What calling an imported function yields.
Sourcefn imported_export(
&self,
from: &FilePath,
module: &str,
name: &ImportedName,
) -> Option<ExportTarget>
fn imported_export( &self, from: &FilePath, module: &str, name: &ImportedName, ) -> Option<ExportTarget>
Where an imported name is actually declared, after every re-export.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".