Function tsconfig::parse_file_to_value [−][src]
pub fn parse_file_to_value<P: AsRef<Path>>(path: &P) -> Result<Value>
Parses a .tsconfig file into a serde_json::Value.
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:
{
"compilerOptions": {
"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::parse_file_to_value; use serde_json::Value; let path = Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()) .join("test/tsconfig.inherits.json"); let config = parse_file_to_value(&path).unwrap(); assert_eq!( config ["compilerOptions"] ["useDefineForClassFields"], Value::Bool(false) );