question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SCC & topological sorting fails for types contained in `declare module`

See original GitHub issue

I’m trying to generate bindings for stream.d.ts from @types/node and do not see sufficient amount of recursive modules in output both in default and in all modes for --rec-modules. Only top level modules seem to be recursed, but not the nested ones. Strongly connected components and topological sorting should be applied to each level in module hierarchy to govern the resulting order and bundling of modules, or I’m missing something?

Command that I’m using:

$ ./node_modules/@ocsigen/ts2ocaml/dist/ts2ocaml.js jsoo \
     -o node \
     --preset=full \
     --readable-names \
     --follow-relative-references \
     --rec-modules all \
     node_modules/@types/node/stream.d.ts

$ grep ' rec ' node/node__stream.mli
module rec Node_stream : sig

ts2ocaml 1.4.2

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Lupuscommented, May 5, 2022

Argh, ignoring invalid options is the most frustrating thing that can happen to the user lol 😄

In my attempts to solve the automated typescript bindings generator I took the path of sorting and bundling recursive modules after all the stuff was already assigned OCaml module names, that worked well - generated code was always sound in terms of recursive modules and ordering of modules. Might not be applicable to ts2ocaml, just sharing my experience 😃

I’ve already recursed the modules by hand while cleaning the definitions emitted by ts2ocaml, not a big deal and still much better than doing everything by hand! Keep up the great work! 👍

0reactions
cannorincommented, May 5, 2022

Argh, ignoring invalid options is the most frustrating thing that can happen to the user lol 😄

I’m releasing 1.4.3 to properly ignore invalid options 😅 , it should be live within few minutes.

just sharing my experience 😃

ts2ocaml used to do this, but at some point I stopped resolving full names on my own and started using TypeScript API (which is mostly undocumented) instead. It seems I ended up shooting myself in the foot…

Keep up the great work! 👍

Thanks❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript module "Node16" does not resolve types of CJS ...
Try `npm i --save-dev @types/colors` if it exists or add a new declaration (.d.ts) file containing `declare module 'colors';` 1 import ...
Read more >
How to sort a list using partial order in Haskell?
The problem with your approach is that your orderStmts is neither an ordering nor a partial ordering. In particular, it's not transitive and ......
Read more >
How to count the number of all topological sorts in a given ...
According to this StackExchange answer by Henning Makholm, this is a hard problem. How many topological orderings exist for a graph?
Read more >
Dependency Analysis of Haskell Declarations - Serokell
Learn how GHC analyzes Haskell code to type-check it in the correct order and what are the flaws of the current implementation.
Read more >
Topological Sorting
Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge u v, vertex u...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found