[−][src]Function dprint_plugin_typescript::format_text
pub fn format_text(
file_path: &str,
file_text: &str,
config: &ResolvedTypeScriptConfiguration
) -> Result<Option<String>, String>
Formats a file.
Example
use dprint_plugin_typescript::*; // resolve the configuration once... let config = TypeScriptConfiguration::new() .line_width(80) .force_multi_line_parameters(true) .force_multi_line_arguments(true) .single_quotes(true) .next_control_flow_position(NextControlFlowPosition::SameLine) .resolve(); // now format many files (consider parallelizing this) let files_to_format = vec![("path/to/file.ts", "const t = 5 ;")]; for (file_path, file_text) in files_to_format { let formatted_text = format_text(file_path, file_text, &config); // ...save formatted_text here... }