pub struct TsConfig {
pub root: bool,
pub path: PathBuf,
pub files: Option<Vec<PathBuf>>,
pub include: Option<Vec<PathBuf>>,
pub exclude: Option<Vec<PathBuf>>,
pub extends: Option<ExtendsField>,
pub compiler_options: CompilerOptions,
pub references: Vec<ProjectReference>,
pub references_resolved: Vec<Arc<Self>>,
/* private fields */
}Fields§
§root: boolWhether this is the caller tsconfig.
false for configs loaded through extends.
path: PathBufPath to tsconfig.json. Contains the tsconfig.json filename.
files: Option<Vec<PathBuf>>§include: Option<Vec<PathBuf>>§exclude: Option<Vec<PathBuf>>§extends: Option<ExtendsField>§compiler_options: CompilerOptions§references: Vec<ProjectReference>§references_resolved: Vec<Arc<Self>>Resolved project references.
Corresponds to each item in TsConfig::references.
Implementations§
Source§impl TsConfig
impl TsConfig
Sourcepub fn parse(
root: bool,
path: &Path,
canonical_path: &Path,
json: String,
) -> Result<Self, Error>
pub fn parse( root: bool, path: &Path, canonical_path: &Path, json: String, ) -> Result<Self, Error>
Parses the tsconfig from a JSON string.
path is the requested path (used as identity for cache lookup and error
reporting). canonical_path anchors baseUrl / paths at the real
tsconfig directory when extends traverses a symlink. Callers that don’t
care about symlinks may pass the same value for both.
§Errors
- Any error that can be returned by
serde_json::from_str().
§Panics
- When
canonical_pathhas no parent directory.
Sourcepub fn root(&self) -> bool
pub fn root(&self) -> bool
Whether this is the caller tsconfig.
false for configs loaded through extends.
Sourcepub fn should_build(&self) -> bool
pub fn should_build(&self) -> bool
Whether build() should normalize paths.
Sourcepub fn set_should_build(&mut self, should_build: bool)
pub fn set_should_build(&mut self, should_build: bool)
Set whether build() should normalize paths.
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Returns the path where the tsconfig.json was found.
Contains the tsconfig.json filename.
Sourcepub fn resolve_path_alias_or_base_url(&self, specifier: &str) -> Vec<PathBuf>
pub fn resolve_path_alias_or_base_url(&self, specifier: &str) -> Vec<PathBuf>
Maps a non-relative module specifier through this tsconfig’s compilerOptions.paths
and baseUrl configuration, returning the mapped absolute path candidates without
checking whether they exist on disk.
Unlike normal resolution (e.g. crate::ResolverImpl::resolve_file), which discards
a paths/baseUrl mapping when the mapped path does not point at a real file, this
keeps the mapping. It is intended for callers that need the alias mapping for a specifier
that is not expected to resolve to a real file, such as glob patterns used by
import.meta.glob (e.g. @/foo/**/*).
Discover the tsconfig for an importing file with crate::ResolverImpl::find_tsconfig,
which resolves project references so the returned config is the one that owns the file.