JavaScript target IDL type object exports and factory function deprecations#665
Conversation
ilbertt
left a comment
There was a problem hiding this comment.
Just to confirm: the use case you are trying to solve is not about being able to programmatically access the args and return types inside functions, right? Otherwise, we may need to export a serviceMethods object, similar to what @nathanosdev was doing in https://github.com/dfinity/candid/pull/610/files#diff-c0a840e21a25105098350b8bb524fa19d48e84949aed98ccbf945da739a1ed79R263-R274.
Btw, we can now make use of the doc comments (similar to what we added in the ts target in #638). I can add them in a separate PR though, so that we keep this one small.
f25c3b7 to
e52a537
Compare
lastmjs
left a comment
There was a problem hiding this comment.
I have addressed all comments and added one more about the naming of idlInitArgs.
ilbertt
left a comment
There was a problem hiding this comment.
I've updated the next branch now. Can you merge it into your branch (again)?
For the rest, I just left a few minor comments. I think we are really close to complete it!
…deprecate the factory functions
fc0f2a8 to
3ef2028
Compare
ilbertt
left a comment
There was a problem hiding this comment.
Already pre-approving, with just a couple of improvements that are not strictly necessary.
ilbertt
left a comment
There was a problem hiding this comment.
I plan to test these changes in a fresh project that uses both agent-js v2 and v3, to check that we don't have regressions. Once done, I'll merge the PR.
ilbertt
left a comment
There was a problem hiding this comment.
If there are no type definitions, the generated file has one more empty line between import statements and export const idlService. Not a big deal, can be left as it is.
Update: I've tested the generated bindings with both agent-js v2 and v3, locally and on mainnet, and I couldn't find any regression. |
Overview
The JavaScript target would be more useful (especially to Azle developers) if it exported the IDL type objects that it generates. We also no longer need the factory functions as of
3.0.0, thus we will mark them deprecated and provide direct exports for that previous functionality.Requirements
The JavaScript target should export all of the IDL type objects, including the generated
IDL.Serviceandinit args, without the need to use a factory function.Considerations
There are no breaking changes besides some formatting of the generated JavaScript files. The
idflFactoryandinitfunctions have been marked as deprecated but not removed. Developers can choose to import theIDLtype objects now, but they are not forced to. This is mainly an ergonomic change with deprecations to prepare for a future with the best developer experience by default.