Closed
Description
Issue created from fantomas-online
Code
$"""{ {| Prop = "XYZ" |} }"""
Result
$"""{{| Prop = "XYZ" |}}"""
Problem description
I'm using Fable and include the React/JSX part in F# via string interpolation like this:
JSX.jsx $"""
<Paper sx={ {| padding = theme.spacing 2 |} }>
...
</Paper>
"""
After Fantomas has reformatted the code and removed the space, the anonymous record is no longer recognized and becomes part of the string because {{ }} are for escaping a { } .
I can workaround it by defining a variable with the anonymous record, but it's quite annoying to do that for every style I need to apply.
let paperSx = {| padding = theme.spacing 2 |}
JSX.jsx $"""
<Paper sx={paperSx}>
...
</Paper>
"""
Thanks.
Extra information
- The formatted result breaks my code.
- The formatted result gives compiler warnings.
- I or my company would be willing to help fix this.
- I would like a release if this problem is solved.
Options
Fantomas main branch at ? - ?
Default Fantomas configuration
Did you know that you can ignore files when formatting by using a .fantomasignore file?
PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.