Skip to content

Non-primitive types in unions #1

Open
@peter-leonov

Description

@peter-leonov

tl;dr Non-primitive types in unions are not currently supported, instead please extract the type that is not supported into a separate type replace it with the type alias name:

// before:
type SomeUnion = string | { name: string; id: number }
// after:
type User = { name: string; id: number }
type SomeUnion = string | User

This is not impossible, but would require either an unstable hack or type definition duplication. Both are cumbersome to support for the end user. As far as the workaround is trivial and provides bullet proof readability and stability, for now we go with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions