Skip to content

Design-type metadata for generic types #11860

Closed
@heruan

Description

@heruan

Design-type metadata such as design:type, design:paramtypes and design:returntype are great to build modern JavaScript frameworks. It would be very useful to also have a design:generics metadata to keep track of generic types, e.g.

class Foo {}
class Bar {}
class Baz {
    map: Map<Foo, Bar>;
}

would transpile to

// ... Foo and Bar functions
var Baz = (function () {
    function Baz() {
    }
    __decorate([
        __metadata('design:type', Map),
        __metadata('design:generics', [ Foo, Bar ]),
    ], Baz.prototype, "map", void 0);
    return Baz;
}());

Activity

mhegazy

mhegazy commented on Oct 26, 2016

@mhegazy
Contributor

The issue of type serialization/"reflection" has been discussed multiple times (#2902, #2577, #3060). we already have #3628 to track this discussion; so i suggest moving this proposal to that issue.

locked and limited conversation to collaborators on Jun 19, 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

        Participants

        @heruan@mhegazy

        Issue actions

          Design-type metadata for generic types · Issue #11860 · microsoft/TypeScript