Skip to content

Improve discriminator type #10

@sschw

Description

@sschw

Right now the type of a discriminator is a string or string union.

This is working but not actually representing the correct type. The type should be the same as the field that the discriminator is used on. Meaning if it is an enum, the discriminator should also be of said enum type instead of a string union.

Therefore we should use the discriminator type and extract the allowed keys of the type.

It seems to be, this type should cover this use case:

(Omit<PropName, 'descriminatorType'> & {
  descriminatorType: Extract<PropName['descriminatorType'], 'decriminator'>;
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions