title: Casting a function parameter object property in Typescript
body: <p>I have a function that looks like this:</p>
  
  <pre><code>getShopItems: async (parent, { payload }, ctx: Context, info) =&gt; { ... }
  </code></pre>
  
  <p>Is there any way to cast the <code>payload</code> property of the second argument? I'd like to do something like this, for example:</p>
  
  <pre><code>getShopItems: async (parent, { payload: ItemSearchPayload }, ctx: Context, info) =&gt; { ... }
  </code></pre>
  
  <p>I'm aware that I can fix this issue by naming the object and casting it to something, a la:</p>
  
  <pre><code>interface Args {
    payload: ItemSearchPayload;
  }
  
  getShopItems: async (parent, args: Args, ctx: Context, info) =&gt; { ... }
  </code></pre>
  
  <p>and in this case I would get typings as expected, but I'm hoping that there's a shortcut because I have a lot of functions like this and I would prefer not to have to create a bunch of interfaces just to use them in one instance like this.</p>