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

How exactly do I convert this file with retyped? #60

Closed idkjs closed 6 years ago

idkjs commented 6 years ago

Basically, I dont know what I'm missing in the docs so I will provide examples below.

Lets say I want to use retyped to create type for a react-apollo Query

Trying retyped on the above, i get:

PrisBook:react-apollo$[develop !] retyped Query.d.ts
Error: Parse_error.Error: undefined
    at Object.compile (/Users/prisc_000/.config/yarn/global/node_modules/reasonably-typed/lib/index.js:60:11)
    at fs.readFile (/Users/prisc_000/.config/yarn/global/node_modules/reasonably-typed/lib/cli.js:56:40)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:528:3)
PrisBook:react-apollo$[develop !]

Trying on Query.js i get:

PrisBook:react-apollo$[develop !] retyped Query.js

✘  Unknown statement type when parsing libdef [in Query.js from 1:0 to 10:5]

> 1 | var __extends = (this && this.__extends) || (function () {
  2 |     var extendStatics = Object.setPrototypeOf ||
  3 |         ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4 |         function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };

Compiled 0 file
There were errors with 1 file

PrisBook:~$ retyped --version 0.13.0 PrisBook:~$ bsc -version BuckleScript 2.2.3 (Using OCaml4.02.3+BS ) PrisBook:~$

Thank you.

rrdelaney commented 6 years ago

ReasonablyTyped is not meant to compile JS into Reason.

Specifically it converts type definitions for Flow and TypeScript into BuckleScript bindings.

The TS conversion on the latest npm release isn't great, and is totally removed in master. Watch out for the next release for better TS conversion.