Skip to content

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

Description

@h0od

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions