-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use this to convert a *.d.t.s file to PS FFI? #1
Comments
Oh sorry. I've already written some spam directly to you Brandon on slack ;-)
Yeah, it is possible, but codegen is not included at the moment in this lib. I've implemented some pieces of codegen based on this lib here: https://github.com/dwhitney/purescript-react-basic-mui/tree/codegen-read-dts/codegen/src This finally should be extracted from the above to a separate repo. There are some dark / hacky corners of our current codegen. Like I've pointed this out on slack already here is the description of the main hack: |
P.S. also union handling which is done in this module is not really smart and I want to improve it soon. |
That would be wonderful if eventually it would be possible to leverage this repository https://github.com/DefinitelyTyped/DefinitelyTyped and create purescript FFI modules automatically :) |
@flip111 Thanks for your interest and comment! We are preparing some video meetup (currently @jvliwanag [GMT+8] and me [GMT +2]). Probably next week. Our ambitious plan is to form a community organization (I think here on github) which could be an umbrella for libraries related to PS codegen from TS. If you Guys (ping @bbarker) want to join you are very welcome! |
Yes please write the details on how to join the video. I'm in the middle of a project at the moment, but generally compiler stuff interest me a lot. |
@flip111 Cool! I hope I will provide more details soon. |
Hmmm, what's the status of this issue? I would like to generate binding to the vscode API using this library but I don't know where to start. |
Hi @poscat0x04 two of the things that are still work in progress are to extract typescript types from definitions files (dts) and to generate purescript code based on this. At the moment both of these things are not ready yet. We welcome you to explore the purescript-codegen space, read issues and send in pull requests if you like. Otherwise please come back later :) |
@poscat0x04 , @flip111 I would not say that type extraction is not ready at the moment. I would say that it works reliably on a subset of TS type constructions. Some of them can be seen here - in this test scenarios (in every test @poscat0x04 Could you please share/link some simple definitions which you want to process? |
@paluh My ultimate goal is to write vscode extensions using purescript, which requires creating a binding to some subset of the api type definitions. |
Tried to use
This is the code I used:
|
@poscat0x04 I've started a branch on which I try to solve ambient module handling. I have hard time extracting declarations from it - this still doesn't work correctly: https://github.com/purescript-codegen/purescript-read-dts/blob/ambient-modules/src/ReadDTS.ts#L176 I'm debugging it here: https://github.com/purescript-codegen/purescript-read-dts/blob/ambient-modules/test/Main.purs#L24 If I leave for example only I'm not sure when I find time to work on modules again. If you need some more debugging tips I can try to provide them here ;-) |
So finally I'm able to somehow handle ambient module declarations. I'm able to build AST for this source: https://github.com/purescript-codegen/purescript-read-dts/blob/ambient-modules/test/Main.purs#L25 There is still a problem with Currently "specialization for module type" has not much sens as far as I can tell... I think that given module declaration you should try to iterate over declarations and process (like specialize or something) them one by one. I have to warn you that AST unfolding has hard coded depth limit and it is known bug (it should be configurable): |
To wrap it up:
|
Tried to run the test on the |
@poscat0x04 I have to admit that @flip111 suggestion that this lib is not ready / stable yet was more insightful then mine opinion which was based mainly on emotions - I've just invested a lot of time in the research and TS compiler api exploration so I "felt" that this code should and is valuable. I'm starting this work on the Sorry that we are not able to meet your expectation at the moment. I hope that with this rewrite we would be able to provide better coverage and docs. I'm going to ping you back when this lib can "digest" |
Or is that even possible?
I certainly don't mind if it isn't perfect, but anything to get me a leg up on converting TypeScript type definitions to PureScript FFI files would be great.
The text was updated successfully, but these errors were encountered: