Skip to content

Emit metadata with union constituents #19154

Closed
@tinganho

Description

@tinganho

Right now, when we emit meta data of one property that is defined as:

class A {
    @Property()
    p1: 's1' | 's2';
}

We emit the metadata as:

__metadata("design:type", String)

So, whoever is using this metadata cannot know the literal types of p1. A library author has to decorate the literal types s1 and s2 in order to access these literal types:

class A {
    @Property(strings: ['s1', 's2'])
    p1: 's1' | 's2';
}

Why don't we just emit it as an array instead?

__metadata("design:type", ['union', 's1', 's2'])

Related to:
#12703

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions