Can Scala.js generate TypeScript type definitions (*.d.ts) for the public API of the module you've compiled with Scala.js?
I asked if this feature exists in a StackOverflow question (currently unanswered). But, I don't think it exists and so am requesting it.
I had actually included Scala.js's support of *.d.ts in Why I like Scala because I thought it already existed. Not sure where I picked that idea up. It'd be great to get this in!
Why implement this? Because TypeScript is increasingly preferred over JavaScript for front end development. Scala.js users are even more likely to use TypeScript than JavaScript because of their interest in strong type systems.
Personal note -- I'd like to use Scala for my backend and cross-compile a subset of my backend with Scala.js to use as a library in create-react-app or next.js. I know Scala.js supports developing entire web apps, but at this point I am mainly interested in using Scala.js for front end libraries due to the pace of change of the web app toolchains.
If you can confirm this feature doesn't currently exist and your willingness to accept a PR for this feature, then I am going to create a Gitcoin bounty, fund it with an initial $50, and ask for other contributions from the Scala community. Maybe we can get this bounty up to a couple hundred dollars and someone could implement this quickly.
I agree that it would be desirable to do, but it should be done as an independent compiler plugin, so this won't happen in this repo. Moreover, the core team does not plan to work on this. We do encourage anyone to contribute such a tool as a separate project. Actually, I think there have been work-in-progress efforts in that direction.
I am going to close this issue because it should be addressed elsewhere.
FWIW: I think this is a really cool idea and you should definitely put out a bounty if you think this would be useful for you.
FTR, there is this work in progress: https://github.com/waveinch/sbt-scalajs-ts-export
I don鈥檛 know if there are other similar initiatives. It would be interesting to list them :)
@sjrd Are there any points to take into account to generate the type definitions?
Most helpful comment
FTR, there is this work in progress: https://github.com/waveinch/sbt-scalajs-ts-export
I don鈥檛 know if there are other similar initiatives. It would be interesting to list them :)