-
-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve throws formatting #591
base: main
Are you sure you want to change the base?
Conversation
e46ab97
to
ea90004
Compare
ea90004
to
e379f32
Compare
@clementdessoude I'm curious what your thoughts are on the formatting decisions I made here. Could you take a look, whenever you have the time? |
@@ -652,15 +658,16 @@ export class ClassesPrettierVisitor extends BaseCstPrettierPrinter { | |||
return printTokenWithComments(this.getSingle(ctx) as IToken); | |||
} | |||
|
|||
throws(ctx: ThrowsCtx) { | |||
throws(ctx: ThrowsCtx, opts?: { throwsGroupId?: symbol }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should throwsGroupId really be optional, or should we force it to be defined so we are "forced" to align throws formating for constructor/interface methods, etc. as well ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I totally forgot to implement this for interface methods. I went ahead and made this required as you suggested, and implemented the same throws formatting for interface methods.
e379f32
to
8ec1626
Compare
What changed with this PR:
Constructors/methods with
throws
clauses now break on their comma-separated list of exception classes rather than violating printWidth, and the left curly brace of the body is broken when this happens in order to separate the exception classes from the body (since they will be at the same indentation).Example
Input
Output
Relative issues or prs:
Closes #286
Closes #429