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

String literal seems cause syntax error #50

Closed kogai closed 6 years ago

kogai commented 6 years ago

When ReasonablyTyped attempt to convert code includes string literal, it generates incorrect syntax

Input

declare module 'literal-type' {
  declare export function f(x: "a" | "b"): void;
}

Output

[@bs.module "literal-type"] external f : (~x:([`a | `b] [@bs.string])) => unit = "";

Probably we expect

[@bs.module "literal-type"] external f : (~x:([@bs.string] [`a | `b])) => unit = "";

0.13.0 (build from source code manually)

BuckleScript 2.2.2 (Using OCaml4.02.3+BS )

kogai commented 6 years ago

Additional, To resolve this issue seems like a good first issue, and it would be an honor for me to tackle to fix it if I can πŸ™

rrdelaney commented 6 years ago

Hey @kogai thanks for reporting the issue and offering to help 😁 this would be a great first issue!

Sorry the contributing docs are a bit rough right now, but running β€œyarn install” should get you up and running. I recommend checking out https://github.com/rrdelaney/ReasonablyTyped/blob/master/src/bsTypeReason.re

kogai commented 6 years ago

Thanks πŸ™ And thanks to using bucklescript, building executable was pretty straightforward πŸ‘

I created PR #51, and when you'd ready to review, please make sure it and point out something noticed πŸ™

rrdelaney commented 6 years ago

Closed by your PR πŸ‘