rrdelaney / ReasonablyTyped

:diamond_shape_with_a_dot_inside: Converts Flow and TypeScript definitions to Reason interfaces
https://rrdelaney.github.io/ReasonablyTyped/
MIT License
518 stars 24 forks source link

Better error output for parse errors #56

Closed kogai closed 6 years ago

kogai commented 6 years ago

Implement pretty-printer of parser-error

Input

Type definition which includes invalid syntax

declare v _;

Output

PR Checklist

rrdelaney commented 6 years ago

This looks great!! Sorry I haven't had the time to review it, but I can get to it this weekend 😄

rrdelaney commented 6 years ago

Rather than doing the error handling + printing in Reason, I think it would be better to return a diagnostic object from compile looking like:

type diagnostic = {.
  "source": string,
  "line": int,
  "col": int
};

and then make compile return:

(string, string, array(diagnostic))

and then the JS code can handle printing and displaying the error.

What do you think?

kogai commented 6 years ago

Sounds great :smile: , let me modify interface :+1: