Skip to content

Typegen Usage which worked with 9.14.2 doesn't work with 10.1.2 #5540

Closed
@rgoulter

Description

@rgoulter
  • I'm submitting a ...

    • Bug report
    • Feature request
    • Support request
    • Other
  • What is the current behavior and expected behavior?

Code which worked with @polkadot/api v9.14.2 doesn't work with v10.1.2. -- Likely same as #5524 (comment)

Some clarification on what changes are needed would be useful.

Example code (& the commands used) can be found here: https://github.com/rgoulter/polkadot-js-typegen-efinity -- It's a pretty bare-bones usage of typegen, to generate the code, and includes a small example TypeScript program which uses the generated types.

The latest commit there updates the @polkadot/typegen to 10.1.2 (and in example/package.json, its @polkadot/api to 10.1.2).

I'm having trouble figuring out what changes I need to make to get it to work with 10.1.2.

What goes wrong:

When it runs polkadot-types-from-defs, it has problems loading the definitions.ts:

> ts-node --skip-project node_modules/.bin/polkadot-types-from-defs --package @efinity/api-augment/interfaces --input ./src/interfaces --endpoint ./metadata.json

ERROR: Unable to load user definitions: Unknown file extension ".ts" for /home/rgoulter/scratch/efinity-api-augment/src/interfaces/definitions.ts

When running polkadot-types-from-chain, some .ts code is generated, but the generated code then leads to errors when trying to build it.

> ts-node --skip-project node_modules/.bin/polkadot-types-from-chain --endpoint ./metadata.json --output ./src/interfaces

Generating from metadata, 254,086 bytes
ERROR: No lookup definitions found: Unknown file extension ".ts" for /home/rgoulter/scratch/efinity-api-augment/src/interfaces/lookup.ts
2023-03-15 14:41:52        REGISTRY: Unknown signed extensions CheckFuelTank found, treating them as no-effect
/home/rgoulter/scratch/efinity-api-augment/src/interfaces/augment-api-consts.ts
        Generating
        Writing

...

Sample errors when trying to run tsc in example:

node_modules/@efinity/api-augment/src/interfaces/augment-api-consts.ts:166:17 - error TS2304: Cannot find name 'FrameSupportPalletId'.

166       palletId: FrameSupportPalletId & AugmentedConst<ApiType>;
                    ~~~~~~~~~~~~~~~~~~~~

...

Found 457 errors in 4 files.

Errors  Files
    11  node_modules/@efinity/api-augment/src/interfaces/augment-api-consts.ts:166
   142  node_modules/@efinity/api-augment/src/interfaces/augment-api-events.ts:43
    86  node_modules/@efinity/api-augment/src/interfaces/augment-api-query.ts:31
   218  node_modules/@efinity/api-augment/src/interfaces/augment-api-tx.ts:23

Problems running with ts-node-esm, too:

If instead of ts-node, I try ts-node-esm, polkadot-types-from-defs abruptly exits without an error message:

> ts-node-esm --skip-project node_modules/.bin/polkadot-types-from-defs --package @efinity/api-augment/interfaces --input ./src/interfaces --endpoint ./metadata.json

/home/rgoulter/scratch/efinity-api-augment/src/interfaces/types.ts
        Generating
        Extracting interfaces for default

If instead of ts-node, I try ts-node-esm, polkadot-types-from-chain is still unable to lookup the definitions:

> @efinity/api-augment@0.0.1 generate:meta
> ts-node-esm --skip-project node_modules/.bin/polkadot-types-from-chain --endpoint ./metadata.json --output ./src/interfaces

Generating from metadata, 254,086 bytes
ERROR: No lookup definitions found: Cannot read properties of undefined (reading 'default')
2023-03-15 14:45:04        REGISTRY: Unknown signed extensions CheckFuelTank found, treating them as no-effect
/
...
  • What is the motivation for changing the behavior?

n/a

  • Please tell us about your environment:

Linux.

$ node --version
v18.12.1

$ npx tsc --version
Version 4.9.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    SupportTracks issues or requests related to troubleshooting, answering questions, and user assistance.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions