polkadot-js / api

Promise and RxJS APIs around Polkadot and Substrate based chains via RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata.
Apache License 2.0
1.07k stars 353 forks source link

How to make type generation work without custom definitions provided? #5566

Open alexxxkny opened 1 year ago

alexxxkny commented 1 year ago

// src/interfaces/definitions.ts export {default as module} from './module/definitions'


For now I have no need to provide our chain's definitions so I wonder is there a more clean solution for this case?
<!---

REQUIRED:

If you're describing a bug, tell us what should happen. If you're
suggesting a change/improvement, tell us how it should work.

-->

* **Please tell us about your environment:**

<!---

REQUIRED:

Include as many relevant details about the environment in which you
experienced the issue. Also ensure that you have tested against the
latest stable releases if you believe this to be a bug

-->

  - Version: 9.14.2
  - Environment:

    - [x] Node.js
    - [ ] Browser
    - [ ] Other (limited support for other environments)

  - Language:

    - [ ] JavaScript
    - [x] TypeScript (Version 4.9.5)
    - [ ] Other
jacogr commented 1 year ago

Not sure there is any solution. (Even in the definitions themeselves, there are sometimes no types, e.g. just RPC/runtime, for those a phantom is add to the contained types.ts, e.g. see https://github.com/polkadot-js/api/blob/master/packages/types/src/interfaces/aura/types.ts#L11)

Happy to accept PRs that cater for empty,

At worst, I suppose the root types.hbs can just get a PHANTOM_GERERATED_<Date.now()> export. Hacky in the same vein as those above and should not create any conflicts. (Not entirely sure how that translated to the handlebars template lange, we potentially need to pass something additional through to the template on generation)