Struct tsconfig::TsConfig [−][src]
pub struct TsConfig { pub exclude: Option<Vec<String>>, pub extends: Option<String>, pub files: Option<Vec<String>>, pub include: Option<Vec<String>>, pub references: Option<References>, pub type_acquisition: Option<TypeAcquisition>, pub compiler_options: Option<CompilerOptions>, }
The main struct representing a parsed .tsconfig file.
Fields
exclude: Option<Vec<String>>
extends: Option<String>
files: Option<Vec<String>>
include: Option<Vec<String>>
references: Option<References>
type_acquisition: Option<TypeAcquisition>
compiler_options: Option<CompilerOptions>
Implementations
impl TsConfig
[src]
impl TsConfig
[src]pub fn parse_file<P: AsRef<Path>>(path: &P) -> Result<TsConfig>
[src]
Parses a .tsconfig file into a TsConfig.
The extends
field will be respected, allowing for one .tsconfig file to inherit properties from another.
Comments and trailing commas are both allowed, although they are not valid JSON.
Example
Assuming the following .tsconfig files:
tsconfig.base.json:
{
"useDefineForClassFields": false,
"traceResolution": true,
"jsx": "preserve",
}
tsconfig.inherits.json:
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"traceResolution": false,
"declaration": true,
"jsx": "react-jsxdev",
}
}
use std::path::Path; use tsconfig::TsConfig; let path = Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()) .join("test/tsconfig.inherits.json"); let config = TsConfig::parse_file(&path).unwrap(); assert_eq!( config .compiler_options .clone() .unwrap() .use_define_for_class_fields, Some(false) ); assert_eq!( config.compiler_options.clone().unwrap().declaration, Some(true) ); assert_eq!( config.compiler_options.unwrap().trace_resolution, Some(false) );
pub fn parse_str(json: &str) -> Result<TsConfig>
[src]
Parse a JSON string into a single TsConfig.
The ‘extends’ field will be ignored. Comments and trailing commas are both allowed, although they are not valid JSON.
Example
use tsconfig::{TsConfig, Jsx}; let json = r#"{"compilerOptions": {"jsx": /*here's a comment*/ "react-jsx"},}"#; let config = TsConfig::parse_str(json).unwrap(); assert_eq!(config.compiler_options.unwrap().jsx, Some(Jsx::ReactJsx));
Trait Implementations
impl<'de> Deserialize<'de> for TsConfig
[src]
impl<'de> Deserialize<'de> for TsConfig
[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl RefUnwindSafe for TsConfig
impl RefUnwindSafe for TsConfig
impl UnwindSafe for TsConfig
impl UnwindSafe for TsConfig
Blanket Implementations
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]