I have a TypeScript code generation scenario, where I construct an AST and then print it and save to a file. The printed class declaration elements, for example, are clustered together. How could one achieve the type of pretty printing that would insert newlines after new method/constructor declarations and perhaps could stack extension methods in new lines?
private baseUrl = "api/students";
constructor(private http: Http) { }
list(): Promise<Student[]> {
return this.http.get(this.baseUrl + "/").toPromise().then((response: Response) => response.json()).catch(this.handleError);
}
get(id: number): Promise<Student> {
return this.http.get(this.baseUrl + ("/" + id)).toPromise().then((response: Response) => response.json()).catch(this.handleError);
}
Any existing API`s can suffice or is there a way to manually insert some trailing trivia after declarations?
ts.SyntaxKind.NewLineTriviaandts.SyntaxKind.WhitespaceTrivia