title: Why doesn't TypeScript work without explicitly specifying an argument type?
body: <p>I create an application that is initialized with a configuration object:</p>
  <pre><code>interface Config&lt;Clients, Users&gt; {
    clients: Record&lt;keyof Clients,(arg: {a: number, b: string}) =&gt; void&gt;
    users: Record&lt;keyof Users, (container: Record&lt;keyof Clients, any&gt;) =&gt; void&gt;
  } 
  
  // And constructor function:
  function create&lt;Clients, Users&gt;(_cfg: Config&lt;Clients, Users&gt;) {
    // ...
  }
  </code></pre>
  <p>Now I will try to call the function with the configuration. When I declare the argument here along with the type, everything works:</p>
  <pre><code>create({
    clients: {
      test: (_arg: {a: number, b: string}) =&gt; {}, // Explicit arg type definition
    },
    users: {
      user1: (clients) =&gt; {
        clients.test // No error here 
      },
    }
  })
  </code></pre>
  <p>But if I skip specifying a type, the &quot;test&quot; key just disappears from the &quot;clients&quot; variable:</p>
  <pre><code>create({
    clients: {
      test: (_arg) =&gt; {}, // When we declare an argument without type, the type of variable 'clients' below becomes 'Record&lt;never, any&gt;'
    },
    users: {
      user1: (clients) =&gt; {
        clients.test // &lt;-- Property 'test' does not exist on type 'Record&lt;never, any&gt;'.
      },
    }
  })
  </code></pre>
  <p>In a real project, the argument has many different properties (like dependency injection), so here I want to use an unpacking of the object without explicitly specifying the type:</p>
  <pre><code>create({
    clients: {
      test: ({a, b}) =&gt; { console.log(a, b) }, // &lt;-- Want to use unpacking without explicitly specifying the type
    },
    users: {
      user1: (clients) =&gt; {
        clients.test // There is an error here 
      },
    }
  })
  </code></pre>
  <p>Can I make TypeScript automatically understand the types of variables &quot;a&quot; and &quot;b&quot; while getting rid of the error <code>Property 'test' does not exist on type 'Record&lt;never, any&gt;'</code>?</p>
  <p>Link to the <a href="https://www.typescriptlang.org/play?ssl=48&amp;ssc=3&amp;pln=37&amp;pc=1#code/PTAEEkDsBcFMCcBmBDAxrUiD29Sq5IgJYDmArvMtEQaFgEYBWsq0AUETAiuqAMIFiJADx8ANkVgwAzgBpQAVWkJpAPlABvNqDwSp0aQC5QAJRY4AJsIDWsAJ5ZE-PTNkAKZPBLGNyY5DIAW3oEeXpjaWh4ThIAXwBKUABedQA3LCILVW1QMmV4I1NzeCtbByclFXk3fBhkTgRjM3wSm3tHZ0lXUGRIO1VElNB0zOzYtjYQfgJI%20DJWHEwySFYaSDZEZdXaVHhYKlhRFwN5SoLVNwB9VERvacJSI66TxXy1RK0dKYA6X7ZxyZgABiRAK0FAsAAHshAgAHMSweQAdxw1mkbF2%20zgbk%20umehVxOjgkWMV08d18-iCIXgYQiURiCWS6g0sXkUwA6gALKSgJEYCwsMSeDDQHk9LxBfSgHl7HpiAgkPlEMWgMWiuywxEQ1IIOximJ81HonRsnJ5FQ%20HI6C3wACMpNQx2kgxZ1p0eP00m%20xPBUwAclgIfB4ItZRh3WbTf94hMpgBlcyQCwQ6FwhHyCwEADk4JR8DRGL2BxxOSd%20KtHrVsBJoDJXldmjZoE5PMgfIFQpFPXb5KlMGVYqwZHB0E12vVavHdCcqU8RGQ9ARoGz5a92dAIQVSM35kCNZXzUswkgsF1tJ7-WzOSjuTelY9toddbXMkbhI9r4MPprfrAAAVQy1eAxxXX0NyzA9ICwcEoSISI6HbMctUPYorFPc95F6K9vkjWQbxjOMwAAFS5UEUyhGF4W1LNIFzI0C3RTES1xL8CXdKYoB6UBizEUBYVDZhWHkSc%2033AcuWQaRQECbDQAsIhEEQBBpQErBgOoA83AkWx5NgLVkykVA7FATghOoAh4nkDiwGkINwwgPlelHIMLR7XJIFhNBrENDpJwYczBy5YdYMheEiFQFUxBM6QtUixA7ENSdkNgQx3V9UlfDCJkhg0PAZiwBFvgVEgPDCRJmxvfCbXvTR3SfR1nXfd0dDYn8EKmUiVNM6TemDUNcAcvCCISCYgA" rel="nofollow noreferrer">playground</a></p>
  <p><strong>UPDATE:</strong>
  I made a new example showing two problems:</p>
  <ol>
  <li>having arguments without explicitly specifying their type causes us to lose the keys of the <code>clients</code> object in <code>command1</code></li>
  <li>I have no idea how to correctly specify the type of <code>Config.commands</code> so that in <code>command1</code> each property would have a different type (<code>Client</code> or derived from it), depending on how they were declared.</li>
  </ol>
  <p><a href="https://www.typescriptlang.org/play?#code/MYGwhgzhAEDCIEsCmA7ALtA3gKGtMAXNCgK4C2ARkgE7QC80ADNrtMAPYoRrUnBrtqACkLFyVagEosrPGgAWCCADow9fKwC%202bdlCQY8ZOliKQAE2hIAHmlTnDiVBhx4KRbtQQoA5uoDkykH%20LHgcXDx8AsKipJQ0ADTQ7tCe3j7SrnipJAAONCKSstAKSsoU6hRaOizedtQAZmDASHCcDQg%20ADxGzhBJsOxkZGAoDgB8MmFO6BBEAEpIHNTmXQDWSACe7A1wM2j90CJEcRJJKWm%200nSTvejjrBzDow4LS4KrG9u7g89jh0JQMYDm9lp8tjs9sDDnc0ONrpMAG7sBDmSYAenR0AA6vIwBgIPJ2CQLNAAJKpfLABANTbQbzcJBgSyQxZg9YQn77GH7SYCaBrFDsADuJXkrRszQwaE2%20XpKDYQxGYwAjAB%20GrYBokFD8BCcNjUJl2aA9bkDJUvCCTQHtTpEQYoDrdWEwy3-eFEZGoqbQTGa4BG-FIIRZIF9IhZabAlVEETnBHEJCi2GFJKY8m7YWtcxLcBG-DUHzkPpJBStAAG4dmFZKsta3mgVfd5hVtaoTyQMArbI%20XRQSERiShznGFeKGeraFjR0TA5T%20yEKsk6axZKzrSNZHYQ7FrTARZLszL4qbU4gtdy1HY%20WoaGQMAPOaQdn4SEsyyN-BAdKEFBIGDZkm75iuwED7kWj4oJswpgJsRTZH6WJTjOxxiPE1DnB4PDpHOyYjugaZIZm0BATYuSINSaA-pSSw0nS5Z1nKkIHsWZClmK%20L%20DAHQDiU7DsEc-4YBSwrEhYKD%20IBozSoJ5iCQgGCDjQDEIOxCHZFOABMcZgAm9CTPOBFoKYCAWPGyQaZoCSPC2cy%20mELaoeeiZRpp3LKChxEALIkNwyStJCMpyrCxTRn0nn7FpPl%20RgVDQEF9bGaZFjFNoeDaJokhAA" rel="nofollow noreferrer">Example in playground</a></p>