question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

inconsistent printing extends for interface and class

See original GitHub issue

Prettier 1.14.3 Playground link

--parser babylon

Input:

interface Foo extends
    VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClassName {}

class Foo extends
    VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClassName {}

Output:

interface Foo
  extends VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClassName {}

class Foo extends VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClassName {}

Expected behavior:

interface Foo extends 
    VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClassName {}

class Foo extends 
    VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClassName {}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
appleseedexmcommented, Aug 26, 2022

Since #13358 is a duplicate of this one (dunno how I missed this while searching for an hour, sorry about that), what’s the current status? That breaking works for implements and combinations with implements and extends, this is should behave exactly the same for extends only.

1reaction
alexander-akaitcommented, Sep 28, 2018

@j-f1 In php we use conditionalGroup for this. Steps:

  • Try to print in one line
interface Foo extends MyClass
{
}
interface Foo extends MyClass, MyOtherClass, OtherClass
{
}
  • Try to print where interface and extends on same line
interface Foo extends
    VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClassName
{
}
interface Foo extends
    MyClass,
    MyOtherClass,
    MyOtherOtherOtherClass,
    MyVeryVeryVeryLongClassName
{
}
  • Try to print where interface and extends on difference line
interface VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClassName
    extends VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClassName
{
}
interface VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClassName
    extends
        MyClass,
        MyOtherClass,
        MyOtherOtherOtherClass,
        MyVeryVeryVeryLongClassName
{
}

Maybe we use same logic here ❓

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inconsistent inheritance of interfaces with generic classes
Take a class hierarchy Chef extends Person extends GraphNode , where each parent class is generic in an interface T that extends the ......
Read more >
Chapter 9. Interfaces
The interface inherits, from the interfaces it extends, all members of those interfaces, except for (a) fields, classes, and interfaces that it hides...
Read more >
577872 – [17] The hierarchy of the type is inconsistent for valid ...
Bug 577872 - [17] The hierarchy of the type is inconsistent for valid sealed type hierarchy when non-sealed types from other packages are...
Read more >
Allow extending multiple interfaces with different, but ...
you can extend multiple interfaces. for classes, you can do this ... That sounds inconsistent, or is there something I'm overlooking here?
Read more >
Object Interfaces - Manual
Interfaces can be extended like classes using the extends operator. Note: The class implementing the interface must declare all methods in the interface...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found