Skip to content
New issue

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

avro-ts: Sometimes fails to mimic the avsc "auto" setting for wrapped unions #141

Open
h0od opened this issue Mar 9, 2023 · 0 comments
Open

Comments

@h0od
Copy link

h0od commented Mar 9, 2023

From to the README of avro-ts

Avro Ts attempts to generate the types of the "auto" setting for wrapped unions.

It does this with the following simple logic on these lines of code:

export const isWrappedUnion = (type: Schema, context: Context): type is WrappedUnionItem[] =>
isUnion(type) &&
type.filter((item) => item !== 'null').length > 1 &&
type.filter((item) => item !== 'null').every((item) => isRecordType(resolveItem(context, item)));

But avsc seem to have a more complex approach as seen here. More specifically in the isAmbiguous() function.

This sometimes leads to failure when trying to encode such message from the types generated by avro-ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant