Skip to content
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

Improve union types with leading comments #5575

Merged
merged 1 commit into from Nov 28, 2018

Commits on Nov 28, 2018

  1. Improve union types with leading comments

    We're running into this issue at Facebook because `// flowfixme` ignores the very next line, but in this case an empty line is added in-between which breaks the fixme.
    
    Ideally the solution is to avoid adding a newline and we'd call it a day. Unfortunately it is tricky to implement in this particular case. The comment is already printed, including its \n. Yet, we want to indent the block and the only way to convince the doc printer to do so is to add an indent group --before-- the \n is printed, otherwise it's just going to indent on the next \n.
    
    So this PR changes the output from one bad way to another, but the new way has the benefit of not breaking flow for Facebook, which makes our internal teams happier.
    
    Note that the way we print the same construct with `&` is broken in the same way as with this PR. https://prettier.io/playground/#N4Igxg9gdgLgprEAuc0DOMAEBbAngNQEMAbAVzkwF5MAKME4+4xhpl5tmgDgHYA2LgE5+g3gP5CRY6cL6iJE2fL4BKJAB0ombTt17tAegOYAwhGzYEMTftu7oFAGSYYAdwjOYACwBOTzABWACYA1gAeXgBmxCFowVEA5jEBaEGJyV6pIdEBCZkhQQGJIcQpXkGRCSFFWaWRXlWlaOWVwZElCUUlAZgqANwgADQgEAAOMACW6MighD4+EK4ACnMIaMgghABuEBNBQyAARj6EYCFwMADKo6cTUAnIMD7kw14w2MQA6l4T8Gg3YDglzWvwmW1+uA2YDQ62GdzQcB8MCWJwS2EIyEiJARwxSYQAQiczhdLoRLAAZO5wTHYuC4tBhS53JJwACKpAg8BpxBxIBuPgRPg2h0Ih1wxGgB1GPjuME+e28yC4AAZhtKIAjPidRhtpXBBVtqcM-ABHUgTPwowhojFILE8ukgBHYCaPZ6OtDM4hsjlcu204YwUXyoKKpAAJkDJwmxGZZgstpAUAcB1ICIAKqL1v6HQBfXNAA
    
    Fixes prettier#5572
    vjeux committed Nov 28, 2018
    Copy the full SHA
    7e5cca8 View commit details
    Browse the repository at this point in the history