title: Access the getter and setter of a typescript property
body: <p>I have a question about typescript properties: Is it possible to get the setter and getter of a typescript property or to declare a function argument to be of a property of X type?</p>
  
  <p>The reason is to get some sort of "reference" to a variable which is not possible in plain JS without writing getter/setter wrappers or access the variable via parent object itself (obj["varname"]).</p>
  
  <p>For example (with some working code and other parts speculative):</p>
  
  <pre><code>//A sample class with a property
  class DataClass&lt;T&gt; {
      private T val;
  
      public get value(): T {
          return this.val;
      }
  
      public set value(value: T) {
          this.val = value;
      }
  }
  
  //Different ways of modifing a member "by reference"
  class ModifyRef {
      public static void DoSomethingByGetterAndSetter(getter: () =&gt; string, setter: (val: string) =&gt; void) {
          var oldValue = getter();
          setter("new value by DoSomethingByGetterAndSetter");
      }
  
      public static void DoSomethingByObject(obj: Object, name: string) {
          var oldValue = obj[name];
          obj[name] = "new value by DoSomethingByObject";
      }
  
      //Is something like this possible?
      public static void DoSomethingByProperty(somePropery: property&lt;string&gt;) {
          var oldVlaue = someProperty;
          someProperty = "new value by DoSomethingByProperty";
      }
  }
  
  var inst = new DataClass&lt;string&gt;();
  
  //Calling the DoSomethingByProperty if possible
  ModifyRef.DoSomethingByProperty(inst.value);
  
  //Or if not is something like this possible
  ModifyRef.DoSomethingByGetterAndSetter(inst.value.get, inst.value.set);
  </code></pre>