title: Why does this React/Redux code typecheck with a seemingly undefined variable?
body: <p>In <a href="https://github.com/reduxjs/redux/blob/master/docs/recipes/WritingTests.md" rel="nofollow noreferrer">the connected components section of the Redux &quot;writing tests&quot; guide</a>, there's a test-utils.js file (copied below):</p>
  <pre class="lang-js prettyprint-override"><code>// test-utils.js
  import React from 'react'
  import { render as rtlRender } from '@testing-library/react'
  import { createStore } from 'redux'
  import { Provider } from 'react-redux'
  
  function render(
    ui,
    {
      initialState,
      store = createStore(reducer, initialState),
      ...renderOptions
    } = {}
  ) {
    function Wrapper({ children }) {
      return &lt;Provider store={store}&gt;{children}&lt;/Provider&gt;
    }
    return rtlRender(ui, { wrapper: Wrapper, ...renderOptions })
  }
  
  // re-export everything
  export * from '@testing-library/react'
  // override render method
  export { render }
  </code></pre>
  <p>It seems like this file is standalone. If we look at the arguments to <code>render</code>, we see <code>store = createStore(reducer, initialState)</code>, which typechecks (!), despite <code>reducer</code> not being defined elsewhere. I can understand why <code>initialState</code>, <code>store</code>, <code>renderOptions</code> are &quot;allowed to be undefined&quot; (because they're arguments to the function!), but does this &quot;propagate&quot; to <code>createStore</code>? If so, how, and what is this behavior called?</p>