dillonkearns / elm-typescript-interop

Generate TypeScript declaration files for your elm ports!
BSD 3-Clause "New" or "Revised" License
165 stars 13 forks source link

Nested function declarations break the compilation #7

Closed tomanders closed 6 years ago

tomanders commented 6 years ago

When I declare an annotated function within a function this causes the compilation to fail with, "expected end of input"

logError : Model -> Http.Error -> Cmd Msg
logError model err =
    let
        errorLog : Http.Error -> String
        errorLog err =
            toString err
    in
        err
            |> errorLog
            |> String.slice 0 200
            |> Debug.log "Error occurred"

When rewriting this with an anonymous function for errorLog, it works again.

dillonkearns commented 6 years ago

Hello @tomanders, sorry for the long delay!

This is an issue with the underlying https://github.com/Bogdanp/elm-ast package. It looks like that package doesn't handle the valid Elm type annotation syntax within lets (you can check this by pasting the above code snippet into http://bogdanp.github.io/elm-ast/example/. Removing the annotation for errorLog fixes it).

It would definitely be nice to see this fixed. I'm going to give it a little time before reporting this, though, since the elm-ast package hasn't upgraded for Elm 0.19 yet, and there are still some other outstanding issues that I'm blocked on as well.

Thank you for filing the issue! I'll keep you posted.

dillonkearns commented 6 years ago

Hello! Thank you for your patience @tomanders. I pushed a fix for this! See the changelog for npm version 0.0.5.