ReasonablyTyped icon indicating copy to clipboard operation
ReasonablyTyped copied to clipboard

Syntax error when using for typescript definitions

Open arnarthor opened this issue 7 years ago • 8 comments

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

  • install retyped 0.11.0
  • install bs-platform 1.9.1
  • yarn add -E [email protected]
  • retyped compile node_modules/raven-js/typescript/raven.d.ts

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 👍

arnarthor avatar Aug 30 '17 14:08 arnarthor

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

rrdelaney avatar Aug 31 '17 00:08 rrdelaney

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

mrmurphy avatar Feb 19 '18 23:02 mrmurphy

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?

zploskey avatar Mar 02 '18 19:03 zploskey

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!

rrdelaney avatar Mar 02 '18 19:03 rrdelaney

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.

zploskey avatar Mar 03 '18 02:03 zploskey

@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.

rrdelaney avatar Mar 25 '18 21:03 rrdelaney

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.

digitake avatar May 23 '18 10:05 digitake

@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.

rrdelaney avatar Jun 06 '18 01:06 rrdelaney