SCC & topological sorting fails for types contained in `declare module`
See original GitHub issueI’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:
- Created a year ago
- Comments:6 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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! 👍
I’m releasing
1.4.3
to properly ignore invalid options 😅 , it should be live within few minutes.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…Thanks❤️