title: Typescript automatic generic type without explicitly declare the type
body: <p>If I have an interface with two functions. one function returns a value. I want to use the type of value in another function in the same interface. I did use generics but I have to explicitly declare the type every time I create new object. but It could be done without it. For example:</p>
  <pre><code>interface MyObject&lt;T&gt; {
      create(): T
      update(value: T): void // use value type defined in create method
  }
  </code></pre>
  <p>and here we define new object using the interface above:</p>
  <pre><code>let test: MyObject&lt;string&gt; = {
      create() {
          return &quot;Hello&quot;
      },
      update(value) {
          // do something with value
      },
  }
  </code></pre>
  <p>It's possible to write <code>MyObject</code> without <code>&lt;string&gt;</code>. as the value type already been defined in <code>create</code> method?</p>