Skip to content

TaggedUnion cannot be used in the manner described in the documentation #1211

@ettmetal

Description

@ettmetal

Bug description

In the example given for TaggedUnion, it demonstrates creating a Tagged type

The demonstration given is type Tagged<Fields extends Record<string, unknown>> = TaggedUnion<'type', Fields>. This makes sense to me as expected behaviour, given the descriptions.

However, even this example fails, with the error "Type 'Fields' does not satisfy the constraint 'Record<string, Record<string, unknown>>'."

It looks like there's a redundant level of Record wrapping the type constraint on TaggedUnion, but even if that's intentional, the example doesn't clarify intended use.

Repro

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBDAnmApnA3gFQIYHNcoAmAqgHbASkC+cAZlBCHAORKoC0tKAzjMwNwBYAFAi2aHPiIAeAGLAUAG0Lc4KAB4wUpFXABKKAMbRC03lGClcAGjgBXUgGtSEAO6kAfB7gBeOJIISckppVmQUZlt5JRUPESA

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions