You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is my personal preference though. Not sure how to simulate that in Prettier for JS. My tries fail miserably - Prettier doesn't want to wrap the extends line, very strange.
That's interesting that it refuses to wrap the extends. It does wrap implements in TypeScript (example), and does so similarly to the method I had gone with for improving throws wrapping in #591 (in that the { is wrapped), except that the implements is always wrapped.
@jtkiesel yes, it's indeed strange that they don't wrap extends but do implements. But even more interesting is that when they do that, they move the opening { on a new line! I've never seen that. This is probably the only case when they put the opening { on a new line instead of the end of the previous one.
But note that this does make it more readable (at least to me) - because of putting { on the next line - it's immediately obvious that the implements line is somehow "separate" from the rest of the code below. Unlike the examples you've given:
By just quickly glancing over such code, it's not immediately clear what happens - i.e. one should move their head and see the { at the end to see where the definition finishes and the implementation begins.
But again - this is very subjective and I just opened the issue for a discussion. I'm absolutely fine with you closing it and leave it as it is.
@boris-petrov I apologize for the confusion, I closed the issue on accident when trying to leave my comment, so I immediately reopened it -- this is a change I want to make, at least for implements.
I think it's very strange (maybe a bug) that extends does something different (compared to implements) in Prettier for JS. I see no reason for that. So if you want to change something, maybe do it for both?
I'll have to think about it all for a bit. I'm guessing the reason implements is formatted differently than extends is because you can implement multiple interfaces but TypeScript (just like Java) doesn't support multiple inheritance.
One potential complication is that in Java, we currently format classes with an empty line after {, while for interfaces we don't. i.e. This might be a bit much:
Activity
jtkiesel commentedon Oct 4, 2025
That's interesting that it refuses to wrap the
extends. It does wrapimplementsin TypeScript (example), and does so similarly to the method I had gone with for improvingthrowswrapping in #591 (in that the{is wrapped), except that theimplementsis always wrapped.boris-petrov commentedon Oct 4, 2025
@jtkiesel yes, it's indeed strange that they don't wrap
extendsbut doimplements. But even more interesting is that when they do that, they move the opening{on a new line! I've never seen that. This is probably the only case when they put the opening{on a new line instead of the end of the previous one.But note that this does make it more readable (at least to me) - because of putting
{on the next line - it's immediately obvious that theimplementsline is somehow "separate" from the rest of the code below. Unlike the examples you've given:By just quickly glancing over such code, it's not immediately clear what happens - i.e. one should move their head and see the
{at the end to see where the definition finishes and the implementation begins.But again - this is very subjective and I just opened the issue for a discussion. I'm absolutely fine with you closing it and leave it as it is.
Thanks!
P.S. some clarifications.
jtkiesel commentedon Oct 4, 2025
@boris-petrov I apologize for the confusion, I closed the issue on accident when trying to leave my comment, so I immediately reopened it -- this is a change I want to make, at least for
implements.boris-petrov commentedon Oct 4, 2025
I think it's very strange (maybe a bug) that
extendsdoes something different (compared toimplements) in Prettier for JS. I see no reason for that. So if you want to change something, maybe do it for both?jtkiesel commentedon Oct 4, 2025
I'll have to think about it all for a bit. I'm guessing the reason
implementsis formatted differently thanextendsis because you can implement multiple interfaces but TypeScript (just like Java) doesn't support multiple inheritance.One potential complication is that in Java, we currently format classes with an empty line after
{, while for interfaces we don't. i.e. This might be a bit much: