We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Depending on the documentation, the enum schema should be
enum
{ enum: [ { struct: { className1: structSchema1 } }, { struct: { className2: structSchema2 } }, ... ] }
Suppose we have a schema like
const borsh_schema = { enum: [ { struct: { transfer: { struct: { recipient: 'string', amount: "u64", }, } } }, { struct: { deploy: { struct: { contract: { array: { type: "u8" } }, cbi_version: "u32", }, } } }, ], }
The type of schema will become (this is intended behavior)
const borsh_schema: { enum: ({ struct: { transfer: { struct: { recipient: string; amount: string; }; }; deploy?: undefined; }; } | { struct: { deploy: { struct: { contract: { array: { type: string; }; }; cbi_version: string; }; }; transfer?: undefined; }; })[]; }
But this will fail the type check when we want to pass schema to (de)serialize
deserialize(borsh_schema, bytes) // this will failed the type check
Typescript Playground: https://tsplay.dev/WPM05w
The text was updated successfully, but these errors were encountered:
Enum works for me. You may be interested in borsher
Sorry, something went wrong.
@kayac-chang I did not understand the issue, could you please share a repo with the error so I can reproduce it and check on it?
No branches or pull requests
Depending on the documentation, the
enum
schema should beSuppose we have a schema like
The type of schema will become (this is intended behavior)
But this will fail the type check when we want to pass schema to (de)serialize
Typescript Playground: https://tsplay.dev/WPM05w
The text was updated successfully, but these errors were encountered: