Skip to content

Get `Error: Comment was not printed' when using flow parser #2555

Closed

Description

@coquelicot

Hi guys, thank you for your great work.

I've just started to use prettier in my react project.
However, I found that prettier raise an "Comment was not printed" error when I switch to use flow parser.

node version: 8.1.2
prettier version: 1.5.3

Here's a minimal example:

import(/**/'m');

The command and output:

$ prettier --parser flow poc/prettier/min.js

poc/prettier/min.js: Error: Comment "" was not printed. Please report this error!
    at astComments.forEach.comment (/Users/liruimin/node_modules/prettier/index.js:13684:13)
    at Array.forEach (native)
    at ensureAllCommentsPrinted (/Users/liruimin/node_modules/prettier/index.js:13682:15)
    at formatWithCursor (/Users/liruimin/node_modules/prettier/index.js:13720:3)
    at Object.formatWithCursor (/Users/liruimin/node_modules/prettier/index.js:13942:12)
    at format (/Users/liruimin/node_modules/prettier/bin/prettier.js:5524:19)
    at filename (/Users/liruimin/node_modules/prettier/bin/prettier.js:5637:16)
    at patterns.forEach.pattern (/Users/liruimin/node_modules/prettier/bin/prettier.js:5703:7)
    at Array.forEach (native)
    at eachFilename (/Users/liruimin/node_modules/prettier/bin/prettier.js:5698:12)

Seems it works perfectly with default parser.

$ prettier poc/prettier/min.js
import(/**/ "m");

Thanks!

Activity

  1. rkurbatov commented on Sep 4, 2017

    @rkurbatov
    Contributor

    The same for 1.6.1 (and the same import() function example btw). I need comments inside of that function call to pass 'chunkName' to webpack2.

  2. lydell commented on Sep 4, 2017

    @lydell
    Member

    @rkurbatov Luckily, there are workarounds until this is fixed: #1489 (comment)

    Closing in favor of #1489 (seems like nobody has noticed the duplicate before).

  3. added
    locked-due-to-inactivity
    on Jul 6, 2018
  4. locked as resolved and limited conversation to collaborators on Jul 6, 2018
  5. added theissue type on Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    locked-due-to-inactivity

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions