ocsigen / ts2ocaml

Generate OCaml bindings from TypeScript definitions via the TypeScript compiler API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot read properties of undefined

joelburget opened this issue · comments

Hi there, I'm very excited about this tool, thank you for writing it! I wanted to report an issue I had running it on the typescript definitions for the Monaco editor (https://github.com/microsoft/monaco-editor/blob/main/monaco-editor/typedoc/monaco.d.ts).

❯ ts2ocaml jsoo --create-minimal-lib --preset=minimal --output-dir src-minimal monaco.d.ts
...
TypeError: Cannot read properties of undefined (reading 'kind')
...

See gist for full output.

I think it has something to do with the version of typescript installed in your npm environment. Can you check and let me know which version is installed in your environment?

I figured it out that TypeScript 4.5.x has the problem.

Not very sure why it breaks since it's a minor version update...

Maybe we have to fix the TypeScript version to prevent this kind of problem.

Thanks for taking a look! I have typescript@4.5.2 in my environment. I see your latest change (db56932) upgrades typescript to that version. Does it work for you? I tried to upgrade with both

  • yarn global upgrade @ocsigen/ts2ocaml -- it looks like the npm package hasn't been updated yet
  • cloning this repo then yarn run ts2ocaml jsoo --create-minimal-lib --preset=minimal --output-dir src-minimal monaco.d.ts -- this failed withError: Cannot find module '/Users/joel/code/ocaml/ts2ocaml/dist/ts2ocaml.js' -- how does one test locally?

Yes, I haven't updated the npm package yet. I will do that in my next work time.

To test ts2ocaml locally, please take a look at https://github.com/ocsigen/ts2ocaml/blob/main/docs/development.md

Version 1.1.0 is now being released. Check out if it fixes the problem for you.

Success! Thank you 🙏🏻