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

Incorrect indentation after interface member with anonymous record as generic type #2396

Closed
1 of 3 tasks
theimowski opened this issue Aug 1, 2022 · 3 comments · Fixed by #2400
Closed
1 of 3 tasks

Comments

@theimowski
Copy link
Member

Issue created from fantomas-online

Code

// ts2fable 0.8.0
module rec Xterm

type [<AllowNullLiteral>] Terminal =
    abstract onKey: IEvent<{| key: string; domEvent: KeyboardEvent |}> with get, set
    abstract onLineFeed: IEvent<unit> with get, set

Result

// ts2fable 0.8.0
module rec Xterm

[<AllowNullLiteral>]
type Terminal =
    abstract onKey:
        IEvent<{| key: string
                  domEvent: KeyboardEvent |}> with get, set

abstract onLineFeed: IEvent<unit> with get, set
  • following error:
(10,0) (10, 8)Error
Unexpected keyword 'abstract' in definition. Expected incomplete structured construct at or before this point or other token.

Problem description

Generated Fable bindings for https://xtermjs.org/ using https://fable.io/ts2fable/ and Fantomas generates invalid F# code when formatting the bindings

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.

Options

Fantomas master branch at 2022-08-01T12:33:32Z - e2eda79

Default Fantomas configuration

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

@nojaf
Copy link
Contributor

nojaf commented Aug 1, 2022

Siema!

I believe this issue can be resolved by changing 0 to 1 in:

if lastIndex < 0 then

This will avoid the additional unindent.

Are you interested in submitting a PR for this?

@theimowski
Copy link
Member Author

Siema :)

Sounds like a serious change - challenge accepted! (will take the credits)

I'll see if I can submit a PR with a test tomorrow 🤞

@nojaf
Copy link
Contributor

nojaf commented Aug 1, 2022

Thanks, you can add the test to ClassTests.
Please checkout the guidelines as well.
Good luck!

nojaf pushed a commit that referenced this issue Aug 2, 2022
…#2396 (#2400)

* Indent interface member after anonymous record as generic type - fixes #2396

* make pre-push script executable to mitigate git warning

* Changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants