Skip to content

[SUGGESTION] Extracting generic type argument #17479

Closed
@npenin

Description

@npenin

The purpose would be to have a class defining some metadata and enriching types on the fly would expose its generic type arguments to be implemented

TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)

Code

class Metadata<T>
{
   constructor()
   {
   }

   public enrich<U>(thing:U):Metadata<T&U>
   {
        //do anything relevant from `thing` like storing its keys
        return <any>this;
   }
}

var meta=new Metadata().enrich({add:true, remove:true})

class Impl implements meta.T
{
/// here add and remove are enforced to be implemented by the typescript compiler
}

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