rrdelaney / ReasonablyTyped

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

Syntax error when using for typescript definitions #40

Open arnarthor opened 7 years ago

arnarthor commented 7 years ago

Description

Tried running retyped compile for raven-js typescript definitions resulting in the following error.

retyped compile node_modules/raven-js/typescript/raven.d.ts
Error: File "", line 49, characters 29-36:
313: <SYNTAX ERROR>

    at Object.compile (/usr/local/lib/node_modules/reasonably-typed/lib/index.js:49:11)
    at fs.readFile.e (/usr/local/lib/node_modules/reasonably-typed/lib/cli.js:86:40)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:446:3)

Step to reproduce

Setup details

retyped --version 0.11.0 bsc -version BuckleScript 1.9.1 (Using OCaml4.02.3+BS )

If you need more details you can ping me on Discord (@arnar) or this issue đź‘Ť

rrdelaney commented 7 years ago

Looks like this is an upstream issue in Flowgen. We have our own Flowgen fork, reasonable-flowgen.

mrmurphy commented 6 years ago

Another instance of what's probably the same issue, while trying to run the parser on https://github.com/firebase/firebase-js-sdk/blob/master/packages/firebase/index.d.ts

Error: Parse_error.Error: undefined
    at Object.compile (/Users/murphy/.nvm/versions/node/v8.9.4/lib/node_modules/reasonably-typed/lib/index.js:60:11)
    at fs.readFile (/Users/murphy/.nvm/versions/node/v8.9.4/lib/node_modules/reasonably-typed/lib/cli.js:56:40)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
retyped --version
0.13.0
zploskey commented 6 years ago

It looks like the dependency on flowgen and even checking if the file is a typescript file was removed in c18c12a60129b5e11daa0f69f3d287fdb97982cb. As it is, it is trying to parse the typescript definitions as flow types. Was this intentional? Should we add back flowgen or reasonable-flowgen, or was there a different approach in mind?

rrdelaney commented 6 years ago

Now that ReasonablyTyped is compiling with BuckleScript, we can start to use JS libraries, specifically the TS parser. Look for ReasonablyTyped-native TS support coming soon :grin:

This means there's some new areas for help, and some new issues I have to create. If anyone is looking for contribution opportunities though, BuckleScript bindings to the TS API would be awesome!

zploskey commented 6 years ago

I've been writing a ton of bindings lately. If you can point me at the specific interfaces that are highest priority for you I could start with those.

rrdelaney commented 6 years ago

@zploskey I'm working on bindings to the TS compiler in bindings/typescript.re. Here's a pretty good example on how to expose an AST node to Reason: https://github.com/rrdelaney/ReasonablyTyped/commit/5046d9d379828a59cf6583aa630f55398bf62d46. I'm using AST Explorer for debugging what nodes have what that are actually useful to ReasonablyTyped.

digitake commented 6 years ago

Are there any simple way to make it works with TypeScript for now? I have tried to contribute but I have no idea which part to start. Ideally, I want to focus on make it works with TypeScript because it seems like there are lots of TypeScript lib compared to flow.

rrdelaney commented 6 years ago

@digitake check out the 2 directory in the root of the project 🙂 that’s the future of the project, and it should be more clear what’s going on in it.