Skip to content

How to use the metadata type in a custom type? #5780

@0xverin

Description

@0xverin
  • I'm submitting a ...
  • Bug report
    Feature request
    Support request
    Other
  • What is the current behavior and expected behavior?
export default {
    types: {
        VCRequested: {
            xxx: "xxx",
            assertion: "Assertion",
        },
        Assertion: {
            xxxx: "xxx"
        }
    }
}

As shown in the above code, Assertion is my custom type, but there is a CorePrimitiveAssertion type within metadata that is identical to Assertion. I want to directly replace it with CorePrimitiveAssertion, but when generating types, I get an error:

build/interfaces/vc/types.ts:266:25 - error TS2304: Cannot find name 'CorePrimitiveAssertion'.

266     readonly assertion: CorePrimitiveAssertion;
                            ~~~~~~~~~~~~~~~~~~~~~~

It seems that CorePrimitiveAssertion is not automatically imported into the generated types.If I manually import the following code in this file, it all works:

import type { CorePrimitivesAssertion } from '@polkadot/types/lookup';

All other types work fine. I just want to replace an existing type in metadata within a custom type. Is this achievable?

  • Please tell us about your environment:
  • Version:

"@polkadot/api": "^10.9.1"

  • Environment:

    • Node.js
      Browser
      Other (limited support for other environments)
  • Language:

    • JavaScript
      TypeScript (include tsc --version)
      Other

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    Status

    Support

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @TarikGul@0xverin

        Issue actions

          How to use the metadata type in a custom type? · Issue #5780 · polkadot-js/api