Emit metadata with union constituents · Issue #19154 · microsoft/TypeScript · GitHub
Skip to content

Emit metadata with union constituents #19154

Closed

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

Activity

  1. mhegazy commented on Oct 14, 2017

    @mhegazy
    Contributor

    The metadata provided are not meant to be a reflective runtime type system. you can find more discussion about this in #3060 and #3628

  2. mhegazy commented on Oct 30, 2017

    @mhegazy
    Contributor

    Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

  3. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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