-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Labels
area:flow comment typeslang:flowIssues affecting Flow-specific constructs (not general JS issues)Issues affecting Flow-specific constructs (not general JS issues)
Description
Prettier 1.9.2
Playground link
--parser flow
Input:
/*::
/* this is a comment *-/
type MyType = {
key: string
}
*/
let foo: MyType = {key: "hello"}
Output:
/* this is a comment */
type MyType = {
key: string
};
let foo: MyType = { key: "hello" };
The /*:: ... */
comment syntax simply parses the comment as if it wasn't a comment at all and the flow parser exposes those as regular nodes.. so we'd need to access the original code to find out if those are comments or not.
I have the following idea:
- before printing every node, go backwards from
node.loc.start
in original text skipping whitespace and check for/*::
.. if found, prepend the node with that. - after printing every node, skip whitespace for
node.loc.end
for*/
. - I think those are safe if we only skip whitespace...
- Figure out a way to handle comments in that case, because they aren't nodes when traversing the API to use the logic above
I'm experimenting with this already but I wanted to gather feedback/opinions/suggestions as well... if anyone wants to collaborate as well let me know
mattsoftware
Metadata
Metadata
Assignees
Labels
area:flow comment typeslang:flowIssues affecting Flow-specific constructs (not general JS issues)Issues affecting Flow-specific constructs (not general JS issues)